Skip to content

Commit

Permalink
changed AJD interface to pass by value
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhughes27 committed Jul 25, 2013
1 parent d2dea43 commit 27a4e9e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/shogun/mathematics/ajd/ApproxJointDiagonalizer.h
Expand Up @@ -54,8 +54,8 @@ class CApproxJointDiagonalizer : public CSGObject
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
virtual SGMatrix<float64_t> compute(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
virtual SGMatrix<float64_t> compute(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/mathematics/ajd/FFDiag.cpp
Expand Up @@ -16,7 +16,7 @@ using namespace shogun;

void getW(double *C, int *ptN, int *ptK, double *W);

SGMatrix<float64_t> CFFDiag::diagonalize(const SGNDArray<float64_t> &C0, SGMatrix<float64_t> V0,
SGMatrix<float64_t> CFFDiag::diagonalize(SGNDArray<float64_t> C0, SGMatrix<float64_t> V0,
double eps, int itermax)
{
int n = C0.dims[0];
Expand Down
8 changes: 4 additions & 4 deletions src/shogun/mathematics/ajd/FFDiag.h
Expand Up @@ -53,8 +53,8 @@ class CFFDiag : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
static SGMatrix<float64_t> diagonalize(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
static SGMatrix<float64_t> diagonalize(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200);

Expand All @@ -65,8 +65,8 @@ class CFFDiag : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
virtual SGMatrix<float64_t> compute(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
virtual SGMatrix<float64_t> compute(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/mathematics/ajd/JADiag.cpp
Expand Up @@ -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<float64_t> CJADiag::diagonalize(const SGNDArray<float64_t> &C, SGMatrix<float64_t> V0,
SGMatrix<float64_t> CJADiag::diagonalize(SGNDArray<float64_t> C, SGMatrix<float64_t> V0,
double eps, int itermax)
{
int d = C.dims[0];
Expand Down
8 changes: 4 additions & 4 deletions src/shogun/mathematics/ajd/JADiag.h
Expand Up @@ -53,8 +53,8 @@ class CJADiag : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
static SGMatrix<float64_t> diagonalize(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
static SGMatrix<float64_t> diagonalize(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200);

Expand All @@ -65,8 +65,8 @@ class CJADiag : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
virtual SGMatrix<float64_t> compute(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
virtual SGMatrix<float64_t> compute(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200)
{
Expand Down
13 changes: 3 additions & 10 deletions src/shogun/mathematics/ajd/JADiagOrth.cpp
Expand Up @@ -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<float64_t> CJADiagOrth::diagonalize(const SGNDArray<float64_t> &C0, SGMatrix<float64_t> V0,
SGMatrix<float64_t> CJADiagOrth::diagonalize(SGNDArray<float64_t> C, SGMatrix<float64_t> 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<float64_t> 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<float64_t> V;
if (V0.num_rows != 0)
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/mathematics/ajd/JADiagOrth.h
Expand Up @@ -53,7 +53,7 @@ class CJADiagOrth : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
static SGMatrix<float64_t> diagonalize(const SGNDArray<float64_t> &C,
static SGMatrix<float64_t> diagonalize(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200);
Expand All @@ -65,7 +65,7 @@ class CJADiagOrth : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
virtual SGMatrix<float64_t> compute(const SGNDArray<float64_t> &C,
virtual SGMatrix<float64_t> compute(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=CMath::MACHINE_EPSILON,
int itermax=200)
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/mathematics/ajd/UWedge.cpp
Expand Up @@ -14,7 +14,7 @@ typedef Matrix< float64_t, Dynamic, Dynamic, ColMajor > EMatrix;

using namespace shogun;

SGMatrix<float64_t> CUWedge::diagonalize(const SGNDArray<float64_t> &C, SGMatrix<float64_t> V0,
SGMatrix<float64_t> CUWedge::diagonalize(SGNDArray<float64_t> C, SGMatrix<float64_t> V0,
double eps, int itermax)
{
int d = C.dims[0];
Expand Down
8 changes: 4 additions & 4 deletions src/shogun/mathematics/ajd/UWedge.h
Expand Up @@ -52,8 +52,8 @@ class CUWedge : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
static SGMatrix<float64_t> diagonalize(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
static SGMatrix<float64_t> diagonalize(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=1e-12,
int itermax=200);

Expand All @@ -64,8 +64,8 @@ class CUWedge : public CApproxJointDiagonalizer
* @param itermax maximum number of iterations
* @return V the matrix that best diagonalizes C
*/
virtual SGMatrix<float64_t> compute(const SGNDArray<float64_t> &C,
SGMatrix<float64_t> V0= SGMatrix<float64_t>(NULL,0,0),
virtual SGMatrix<float64_t> compute(SGNDArray<float64_t> C,
SGMatrix<float64_t> V0 = SGMatrix<float64_t>(NULL,0,0),
double eps=1e-12,
int itermax=200)
{
Expand Down

0 comments on commit 27a4e9e

Please sign in to comment.