Skip to content

Commit

Permalink
Remove lauum
Browse files Browse the repository at this point in the history
  • Loading branch information
wlevine committed Aug 7, 2015
1 parent 18850f8 commit 1cf8907
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 89 deletions.
10 changes: 0 additions & 10 deletions ext/nmatrix/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ extern "C" {
static VALUE nm_clapack_getri(VALUE self, VALUE order, VALUE n, VALUE a, VALUE lda, VALUE ipiv);
static VALUE nm_clapack_potri(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda);
static VALUE nm_clapack_laswp(VALUE self, VALUE n, VALUE a, VALUE lda, VALUE k1, VALUE k2, VALUE ipiv, VALUE incx);
static VALUE nm_clapack_lauum(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda);

static VALUE nm_lapack_gesvd(VALUE self, VALUE jobu, VALUE jobvt, VALUE m, VALUE n, VALUE a, VALUE lda, VALUE s, VALUE u, VALUE ldu, VALUE vt, VALUE ldvt, VALUE lworkspace_size);
static VALUE nm_lapack_gesdd(VALUE self, VALUE jobz, VALUE m, VALUE n, VALUE a, VALUE lda, VALUE s, VALUE u, VALUE ldu, VALUE vt, VALUE ldvt, VALUE lworkspace_size);
Expand Down Expand Up @@ -503,7 +502,6 @@ void nm_math_init_blas() {
rb_define_singleton_method(cNMatrix_Internal_LAPACK, "clapack_getri", (METHOD)nm_clapack_getri, 5);
rb_define_singleton_method(cNMatrix_Internal_LAPACK, "clapack_potri", (METHOD)nm_clapack_potri, 5);
rb_define_singleton_method(cNMatrix_Internal_LAPACK, "clapack_laswp", (METHOD)nm_clapack_laswp, 7);
rb_define_singleton_method(cNMatrix_Internal_LAPACK, "clapack_lauum", (METHOD)nm_clapack_lauum, 5);

/* Non-ATLAS regular LAPACK Functions called via Fortran interface */
rb_define_singleton_method(cNMatrix_Internal_LAPACK, "lapack_gesvd", (METHOD)nm_lapack_gesvd, 12);
Expand Down Expand Up @@ -1060,14 +1058,6 @@ static VALUE nm_lapack_geev(VALUE self, VALUE compute_left, VALUE compute_right,
return Qfalse;
}


static VALUE nm_clapack_lauum(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda) {
//should I remove this entirely?
rb_raise(rb_eNotImpError, "not implemented without external libraries");
return Qfalse;
}


/* Call any of the clapack_xgetrf functions as directly as possible.
*
* The clapack_getrf functions (dgetrf, sgetrf, cgetrf, and zgetrf) compute an LU factorization of a general M-by-N
Expand Down
27 changes: 0 additions & 27 deletions ext/nmatrix_atlas/math_atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extern "C" {
static VALUE nm_atlas_clapack_getri(VALUE self, VALUE order, VALUE n, VALUE a, VALUE lda, VALUE ipiv);
static VALUE nm_atlas_clapack_potri(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda);
static VALUE nm_atlas_clapack_laswp(VALUE self, VALUE n, VALUE a, VALUE lda, VALUE k1, VALUE k2, VALUE ipiv, VALUE incx);
static VALUE nm_atlas_clapack_lauum(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda);

static VALUE nm_atlas_lapack_gesvd(VALUE self, VALUE jobu, VALUE jobvt, VALUE m, VALUE n, VALUE a, VALUE lda, VALUE s, VALUE u, VALUE ldu, VALUE vt, VALUE ldvt, VALUE lworkspace_size);
static VALUE nm_atlas_lapack_gesdd(VALUE self, VALUE jobz, VALUE m, VALUE n, VALUE a, VALUE lda, VALUE s, VALUE u, VALUE ldu, VALUE vt, VALUE ldvt, VALUE lworkspace_size);
Expand Down Expand Up @@ -116,7 +115,6 @@ void nm_math_init_atlas() {
rb_define_singleton_method(cNMatrix_ATLAS_LAPACK, "clapack_getri", (METHOD)nm_atlas_clapack_getri, 5);
rb_define_singleton_method(cNMatrix_ATLAS_LAPACK, "clapack_potri", (METHOD)nm_atlas_clapack_potri, 5);
rb_define_singleton_method(cNMatrix_ATLAS_LAPACK, "clapack_laswp", (METHOD)nm_atlas_clapack_laswp, 7);
rb_define_singleton_method(cNMatrix_ATLAS_LAPACK, "clapack_lauum", (METHOD)nm_atlas_clapack_lauum, 5);

/* Non-ATLAS regular LAPACK Functions called via Fortran interface */
rb_define_singleton_method(cNMatrix_ATLAS_LAPACK, "lapack_gesvd", (METHOD)nm_atlas_lapack_gesvd, 12);
Expand Down Expand Up @@ -867,31 +865,6 @@ static VALUE nm_atlas_lapack_geev(VALUE self, VALUE compute_left, VALUE compute_
}
}

static VALUE nm_atlas_clapack_lauum(VALUE self, VALUE order, VALUE uplo, VALUE n, VALUE a, VALUE lda) {
static int (*ttable[nm::NUM_DTYPES])(const enum CBLAS_ORDER, const enum CBLAS_UPLO, const int n, void* a, const int lda) = {
NULL, NULL, NULL, NULL, NULL,
nm::math::atlas::clapack_lauum<float>,
nm::math::atlas::clapack_lauum<double>,
#if defined (HAVE_CLAPACK_H) || defined (HAVE_ATLAS_CLAPACK_H)
clapack_clauum, clapack_zlauum, // call directly, same function signature!
#else // Especially important for Mac OS, which doesn't seem to include the ATLAS clapack interface.
nm::math::atlas::clapack_lauum<nm::Complex64>,
nm::math::atlas::clapack_lauum<nm::Complex128>,
#endif
NULL
};

if (!ttable[NM_DTYPE(a)]) {
rb_raise(rb_eNotImpError, "does not yet work for non-BLAS dtypes (needs herk, syrk, trmm)");
} else {
// Call either our version of lauum or the LAPACK version.
ttable[NM_DTYPE(a)](blas_order_sym(order), blas_uplo_sym(uplo), FIX2INT(n), NM_STORAGE_DENSE(a)->elements, FIX2INT(lda));
}

return a;
}


/* Call any of the clapack_xgetrf functions as directly as possible.
*
* The clapack_getrf functions (dgetrf, sgetrf, cgetrf, and zgetrf) compute an LU factorization of a general M-by-N
Expand Down
42 changes: 0 additions & 42 deletions ext/nmatrix_atlas/math_atlas/clapack_templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,48 +298,6 @@ inline int clapack_potrs(const enum CBLAS_ORDER order, const enum CBLAS_UPLO upl
return potrs<DType>(order, uplo, n, nrhs, static_cast<const DType*>(a), lda, static_cast<DType*>(b), ldb);
}

//lauum
template <typename DType>
inline void lauum(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int N, DType* A, const int lda) {
#if defined HAVE_CLAPACK_H || defined HAVE_ATLAS_CLAPACK_H
rb_raise(rb_eNotImpError, "not yet implemented for non-BLAS dtypes");
#else
rb_raise(rb_eNotImpError, "only CLAPACK version implemented thus far");
#endif
}

#if defined HAVE_CLAPACK_H || defined HAVE_ATLAS_CLAPACK_H
template <>
inline void lauum<float>(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int N, float* A, const int lda) {
clapack_slauum(order, uplo, N, A, lda);
}

template <>
inline void lauum<double>(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int N, double* A, const int lda) {
clapack_dlauum(order, uplo, N, A, lda);
}

template <>
inline void lauum<Complex64>(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int N, Complex64* A, const int lda) {
clapack_clauum(order, uplo, N, A, lda);
}

template <>
inline void lauum<Complex128>(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int N, Complex128* A, const int lda) {
clapack_zlauum(order, uplo, N, A, lda);
}
#endif

template <typename DType>
inline int clapack_lauum(const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const int n, void* a, const int lda) {
if (n < 0) rb_raise(rb_eArgError, "n cannot be less than zero, is set to %d", n);
if (lda < n || lda < 1) rb_raise(rb_eArgError, "lda must be >= max(n,1); lda=%d, n=%d\n", lda, n);

lauum<DType>(order, uplo, n, static_cast<DType*>(a), lda);

return 0;
}

}}}

#endif
10 changes: 0 additions & 10 deletions spec/plugins/atlas/atlas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@

expect(b).to be_within(err).of(x)
end

#This spec should include separate tests for complex types and also tests for :lower
#lauum is supposed to calculate the upper/lower part of U*U^T or L^T*L for triangular matrices
it "exposes clapack_lauum" do
a = NMatrix.new([3,3],[1,2,3, 0,4,5, 0,0,10], dtype: dtype)
NMatrix::LAPACK.clapack_lauum(:row, :upper, 3, a, 3)
b = NMatrix.new([3,3],[14,23,30, 0,41,50, 0,0,100], dtype: dtype)

expect(a).to eq(b)
end
end
end

Expand Down

0 comments on commit 1cf8907

Please sign in to comment.