diff --git a/src/shogun/mathematics/ajd/ApproxJointDiagonalizer.h b/src/shogun/mathematics/ajd/ApproxJointDiagonalizer.h index 2f6fc115c09..3d84d71c3a9 100644 --- a/src/shogun/mathematics/ajd/ApproxJointDiagonalizer.h +++ b/src/shogun/mathematics/ajd/ApproxJointDiagonalizer.h @@ -54,8 +54,8 @@ class CApproxJointDiagonalizer : public CSGObject * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - virtual SGMatrix compute(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + virtual SGMatrix compute(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200) = 0; diff --git a/src/shogun/mathematics/ajd/FFDiag.cpp b/src/shogun/mathematics/ajd/FFDiag.cpp index 1adc82702a4..365ede1d0a4 100644 --- a/src/shogun/mathematics/ajd/FFDiag.cpp +++ b/src/shogun/mathematics/ajd/FFDiag.cpp @@ -16,7 +16,7 @@ using namespace shogun; void getW(double *C, int *ptN, int *ptK, double *W); -SGMatrix CFFDiag::diagonalize(const SGNDArray &C0, SGMatrix V0, +SGMatrix CFFDiag::diagonalize(SGNDArray C0, SGMatrix V0, double eps, int itermax) { int n = C0.dims[0]; diff --git a/src/shogun/mathematics/ajd/FFDiag.h b/src/shogun/mathematics/ajd/FFDiag.h index ddb1e392e94..85d27679b79 100644 --- a/src/shogun/mathematics/ajd/FFDiag.h +++ b/src/shogun/mathematics/ajd/FFDiag.h @@ -53,8 +53,8 @@ class CFFDiag : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - static SGMatrix diagonalize(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + static SGMatrix diagonalize(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200); @@ -65,8 +65,8 @@ class CFFDiag : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - virtual SGMatrix compute(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + virtual SGMatrix compute(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200) { diff --git a/src/shogun/mathematics/ajd/JADiag.cpp b/src/shogun/mathematics/ajd/JADiag.cpp index 47268b3af05..256cb975ddd 100644 --- a/src/shogun/mathematics/ajd/JADiag.cpp +++ b/src/shogun/mathematics/ajd/JADiag.cpp @@ -17,7 +17,7 @@ using namespace shogun; void jadiagw(double c[], double w[], int *ptn, int *ptm, double a[], double *logdet, double *decr, double *result); -SGMatrix CJADiag::diagonalize(const SGNDArray &C, SGMatrix V0, +SGMatrix CJADiag::diagonalize(SGNDArray C, SGMatrix V0, double eps, int itermax) { int d = C.dims[0]; diff --git a/src/shogun/mathematics/ajd/JADiag.h b/src/shogun/mathematics/ajd/JADiag.h index 73dc1159850..db36337cfda 100644 --- a/src/shogun/mathematics/ajd/JADiag.h +++ b/src/shogun/mathematics/ajd/JADiag.h @@ -53,8 +53,8 @@ class CJADiag : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - static SGMatrix diagonalize(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + static SGMatrix diagonalize(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200); @@ -65,8 +65,8 @@ class CJADiag : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - virtual SGMatrix compute(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + virtual SGMatrix compute(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200) { diff --git a/src/shogun/mathematics/ajd/JADiagOrth.cpp b/src/shogun/mathematics/ajd/JADiagOrth.cpp index 565d27e7556..fc60180d82c 100644 --- a/src/shogun/mathematics/ajd/JADiagOrth.cpp +++ b/src/shogun/mathematics/ajd/JADiagOrth.cpp @@ -19,18 +19,11 @@ void left_rot_stack(double *A, int M, int N, int K, int p, int q, double c, doub void right_rot_stack(double *A, int M, int N, int K, int p, int q, double c, double s); void left_rot_simple(double *A, int m, int n, int p, int q, double c, double s); -SGMatrix CJADiagOrth::diagonalize(const SGNDArray &C0, SGMatrix V0, +SGMatrix CJADiagOrth::diagonalize(SGNDArray C, SGMatrix V0, double eps, int itermax) { - int m = C0.dims[0]; - int L = C0.dims[2]; - - index_t * C_dims = SG_MALLOC(index_t, 3); - C_dims[0] = C0.dims[0]; - C_dims[1] = C0.dims[1]; - C_dims[2] = C0.dims[2]; - SGNDArray C(C_dims,3); - memcpy(C.array, C0.array, C0.dims[0]*C0.dims[1]*C0.dims[2]*sizeof(float64_t)); + int m = C.dims[0]; + int L = C.dims[2]; SGMatrix V; if (V0.num_rows != 0) diff --git a/src/shogun/mathematics/ajd/JADiagOrth.h b/src/shogun/mathematics/ajd/JADiagOrth.h index 1a2c6b4136e..e1a8ce78a3d 100644 --- a/src/shogun/mathematics/ajd/JADiagOrth.h +++ b/src/shogun/mathematics/ajd/JADiagOrth.h @@ -53,7 +53,7 @@ class CJADiagOrth : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - static SGMatrix diagonalize(const SGNDArray &C, + static SGMatrix diagonalize(SGNDArray C, SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200); @@ -65,7 +65,7 @@ class CJADiagOrth : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - virtual SGMatrix compute(const SGNDArray &C, + virtual SGMatrix compute(SGNDArray C, SGMatrix V0 = SGMatrix(NULL,0,0), double eps=CMath::MACHINE_EPSILON, int itermax=200) diff --git a/src/shogun/mathematics/ajd/UWedge.cpp b/src/shogun/mathematics/ajd/UWedge.cpp index ee2f69e6c70..629894fc846 100644 --- a/src/shogun/mathematics/ajd/UWedge.cpp +++ b/src/shogun/mathematics/ajd/UWedge.cpp @@ -14,7 +14,7 @@ typedef Matrix< float64_t, Dynamic, Dynamic, ColMajor > EMatrix; using namespace shogun; -SGMatrix CUWedge::diagonalize(const SGNDArray &C, SGMatrix V0, +SGMatrix CUWedge::diagonalize(SGNDArray C, SGMatrix V0, double eps, int itermax) { int d = C.dims[0]; diff --git a/src/shogun/mathematics/ajd/UWedge.h b/src/shogun/mathematics/ajd/UWedge.h index 5f4fc9799c2..c0443be8472 100644 --- a/src/shogun/mathematics/ajd/UWedge.h +++ b/src/shogun/mathematics/ajd/UWedge.h @@ -52,8 +52,8 @@ class CUWedge : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - static SGMatrix diagonalize(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + static SGMatrix diagonalize(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=1e-12, int itermax=200); @@ -64,8 +64,8 @@ class CUWedge : public CApproxJointDiagonalizer * @param itermax maximum number of iterations * @return V the matrix that best diagonalizes C */ - virtual SGMatrix compute(const SGNDArray &C, - SGMatrix V0= SGMatrix(NULL,0,0), + virtual SGMatrix compute(SGNDArray C, + SGMatrix V0 = SGMatrix(NULL,0,0), double eps=1e-12, int itermax=200) {