From 0a195e12138a11f76d8e9f0280ac6a74180ffb96 Mon Sep 17 00:00:00 2001 From: jiri Date: Fri, 22 Jun 2007 14:24:55 +0000 Subject: [PATCH] *** empty log message *** --- mat.cc | 44 ++++++++++++++++++++++++++++++++++++++++++-- noncblas.cc | 6 ++++-- nonclass.cc | 13 ++++++++++++- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/mat.cc b/mat.cc index 45febb9..cd46da6 100644 --- a/mat.cc +++ b/mat.cc @@ -16,6 +16,48 @@ extern ssize_t write(int, const void *, size_t); * Templates first, specializations for BLAS next */ + + +//direct sum +template +const NRMat NRMat::oplus(const NRMat &rhs) const +{ +NRMat r((T)0,nn+rhs.nn,mm+rhs.mm); + +#ifdef oldversion +int i,j; +for(i=0;i +const NRMat NRMat::otimes(const NRMat &rhs) const +{ +NRMat r((T)0,nn*rhs.nn,mm*rhs.mm); + +int i,j,k,l; + +for(i=0;i const NRVec NRMat::row(const int i, int l) const @@ -251,7 +293,6 @@ int torow=fromrow+rhs.nrows()-1; #ifdef DEBUG if(fromrow <0 ||fromrow >=nn||torow >=nn ||fromcol<0||fromcol>=mm||tocol>=mm) laerror("bad indices in storesubmatrix"); #endif -int n=torow-fromrow+1; int m=tocol-fromcol+1; for(int i=fromrow; i<=torow; ++i) #ifdef MATPTR @@ -1068,7 +1109,6 @@ return divide?NULL:&r[0]; -//direct sum and product (oplus, otimes) to be done diff --git a/noncblas.cc b/noncblas.cc index 049157a..75dad88 100644 --- a/noncblas.cc +++ b/noncblas.cc @@ -109,6 +109,7 @@ FORNAME(zdotc) (dotc,&N,X,&incX,Y,&incY); //enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 }; //enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113, AtlasConj=114}; + extern "C" void FORNAME(dspmv) (const char *uplo, const int *n, const double *alpha, const double *ap, const double *x, const int *incx, const double *beta, double *y, const int *incy); void cblas_dspmv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const int N, const double alpha, const double *Ap, @@ -117,9 +118,10 @@ void cblas_dspmv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, { if(Order!=CblasRowMajor) laerror("CblasRowMajor order asserted"); if(Uplo!=CblasLower) laerror("CblasLower uplo asserted"); -FORNAME(dspmv) ("L",&N, &alpha, Ap, X, &incX, &beta, Y, &incY); +FORNAME(dspmv) ("U",&N, &alpha, Ap, X, &incX, &beta, Y, &incY); } + extern "C" void FORNAME(zhpmv) (const char *uplo, const int *n, const void *alpha, const void *ap, const void *x, const int *incx, const void *beta, void *y, const int *incy); void cblas_zhpmv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const int N, const void *alpha, const void *Ap, @@ -128,7 +130,7 @@ void cblas_zhpmv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, { if(Order!=CblasRowMajor) laerror("CblasRowMajor order asserted"); if(Uplo!=CblasLower) laerror("CblasLower uplo asserted"); -FORNAME(zhpmv) ("L",&N, alpha, Ap, X, &incX, beta, Y, &incY); +FORNAME(zhpmv) ("U",&N, alpha, Ap, X, &incX, beta, Y, &incY); } diff --git a/nonclass.cc b/nonclass.cc index af5d666..c33ccca 100644 --- a/nonclass.cc +++ b/nonclass.cc @@ -137,9 +137,20 @@ static void linear_solve_do(NRMat &A, double *B, const int nrhs, const i //take into account some numerical instabilities in dgesv for singular matrices for (int i=0; i0) *det = 0; +/* + cout <<"ipiv = "; + for (int i=0; i0 && B) laerror("singular matrix in lapack_gesv"); }