diff -r cb4bd6829f52 include/petscmath.h --- a/include/petscmath.h Wed Jun 28 17:38:54 2006 -0400 +++ b/include/petscmath.h Fri Jun 30 11:28:20 2006 +0200 @@ -27,9 +27,9 @@ extern MPI_Datatype PETSC_DLLEXPORT MPI #define PetscExpPassiveScalar(a) PetscExpScalar() #if defined(PETSC_USE_COMPLEX) - -/* - PETSc now only supports std::complex +#if defined(PETSC_CLANGUAGE_CXX) +/* + C++ support of complex numbers: Original support */ #include @@ -52,6 +52,34 @@ extern MPI_Datatype PETSC_DLLEXPORT MPI #define PetscCosScalar(a) std::cos(a) typedef std::complex PetscScalar; +#else +#include + +/* + C support of complex numbers: Warning it needs a + C90 compliant compiler to work... + */ + +extern MPI_Datatype PETSC_DLLEXPORT MPIU_COMPLEX; +#define MPIU_SCALAR MPIU_COMPLEX +#if defined(PETSC_USE_MAT_SINGLE) +#define MPIU_MATSCALAR ??Notdone +#else +#define MPIU_MATSCALAR MPIU_COMPLEX +#endif + +#define PetscRealPart(a) creal(a) +#define PetscImaginaryPart(a) cimag(a) +#define PetscAbsScalar(a) cabs(a) +#define PetscConj(a) conj(a) +#define PetscSqrtScalar(a) csqrt(a) +#define PetscPowScalar(a,b) cpow(a,b) +#define PetscExpScalar(a) cexp(a) +#define PetscSinScalar(a) csin(a) +#define PetscCosScalar(a) ccos(a) + +typedef double complex PetscScalar; +#endif /* Compiling for real numbers only */ #else diff -r cb4bd6829f52 python/PETSc/utilities/languages.py --- a/python/PETSc/utilities/languages.py Wed Jun 28 17:38:54 2006 -0400 +++ b/python/PETSc/utilities/languages.py Fri Jun 30 11:28:20 2006 +0200 @@ -69,8 +69,8 @@ class Configure(config.base.Configure): self.clanguage = self.framework.argDB['with-clanguage'].upper().replace('+','x').replace('X','x') if not self.clanguage in ['C', 'Cxx']: raise RuntimeError('Invalid C language specified: '+str(self.clanguage)) - if self.scalartype == 'complex': - self.clanguage = 'Cxx' +# if self.scalartype == 'complex': +# self.clanguage = 'Cxx' if self.clanguage == 'C' and not self.framework.argDB['with-c++-support'] and not self.packagesHaveCxx(): self.framework.argDB['with-cxx'] = '0' self.framework.logPrint('Turning off C++ support') diff -r cb4bd6829f52 src/mat/impls/aij/mpi/mpiaij.c --- a/src/mat/impls/aij/mpi/mpiaij.c Wed Jun 28 17:38:54 2006 -0400 +++ b/src/mat/impls/aij/mpi/mpiaij.c Fri Jun 30 11:28:20 2006 +0200 @@ -2285,7 +2285,7 @@ EXTERN_C_BEGIN EXTERN_C_BEGIN #undef __FUNCT__ #define __FUNCT__ "MatMPIAIJSetPreallocationCSR_MPIAIJ" -PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR_MPIAIJ(Mat B,const PetscInt I[],const PetscInt J[],const PetscScalar v[]) +PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR_MPIAIJ(Mat B,const PetscInt Ii[],const PetscInt J[],const PetscScalar v[]) { PetscInt m,cstart, cend,j,nnz,i,d; PetscInt *d_nnz,*o_nnz,nnz_max = 0,rstart,ii; @@ -2294,7 +2294,7 @@ PetscErrorCode PETSCMAT_DLLEXPORT MatMPI PetscErrorCode ierr; PetscFunctionBegin; - if (I[0]) SETERRQ1(PETSC_ERR_ARG_OUTOFRANGE,"I[0] must be 0 it is %D",I[0]); + if (Ii[0]) SETERRQ1(PETSC_ERR_ARG_OUTOFRANGE,"Ii[0] must be 0 it is %D",Ii[0]); B->rmap.bs = B->cmap.bs = 1; ierr = PetscMapInitialize(B->comm,&B->rmap);CHKERRQ(ierr); @@ -2308,8 +2308,8 @@ PetscErrorCode PETSCMAT_DLLEXPORT MatMPI o_nnz = d_nnz + m; for (i=0; idata; PetscInt m = B->rmap.n/bs,cstart = baij->cstartbs, cend = baij->cendbs,j,nnz,i,d; @@ -2114,14 +2114,14 @@ PetscErrorCode MatMPIBAIJSetPreallocatio PetscFunctionBegin; #if defined(PETSC_OPT_g) - if (I[0]) SETERRQ1(PETSC_ERR_ARG_RANGE,"I[0] must be 0 it is %D",I[0]); + if (Ii[0]) SETERRQ1(PETSC_ERR_ARG_RANGE,"Ii[0] must be 0 it is %D",Ii[0]); #endif ierr = PetscMalloc((2*m+1)*sizeof(PetscInt),&d_nnz);CHKERRQ(ierr); o_nnz = d_nnz + m; for (i=0; i i[j]) { - SWAP2(i[k],i[j],I[k],I[j],tmp); - ik = i[k]; - } - } - } - } else { - ierr = PetscSortIntWithArray_Private(i,I,n-1);CHKERRQ(ierr); + SWAP2(i[k],i[j],Ii[k],Ii[j],tmp); + ik = i[k]; + } + } + } + } else { + ierr = PetscSortIntWithArray_Private(i,Ii,n-1);CHKERRQ(ierr); } PetscFunctionReturn(0); } @@ -211,7 +211,7 @@ static PetscErrorCode PetscSortIntWithSc .seealso: PetscSortReal(), PetscSortIntPermutation(), PetscSortInt(), PetscSortIntWithArray() @*/ -PetscErrorCode PETSC_DLLEXPORT PetscSortIntWithScalarArray(PetscInt n,PetscInt i[],PetscScalar I[]) +PetscErrorCode PETSC_DLLEXPORT PetscSortIntWithScalarArray(PetscInt n,PetscInt i[],PetscScalar Ii[]) { PetscErrorCode ierr; PetscInt j,k,tmp,ik; @@ -223,15 +223,15 @@ PetscErrorCode PETSC_DLLEXPORT PetscSort ik = i[k]; for (j=k+1; j i[j]) { - SWAP2IntScalar(i[k],i[j],I[k],I[j],tmp,stmp); - ik = i[k]; - } - } - } - } else { - ierr = PetscSortIntWithScalarArray_Private(i,I,n-1);CHKERRQ(ierr); - } - PetscFunctionReturn(0); -} - - + SWAP2IntScalar(i[k],i[j],Ii[k],Ii[j],tmp,stmp); + ik = i[k]; + } + } + } + } else { + ierr = PetscSortIntWithScalarArray_Private(i,Ii,n-1);CHKERRQ(ierr); + } + PetscFunctionReturn(0); +} + +