IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26346


Ignore:
Timestamp:
Dec 6, 2009, 8:41:25 AM (16 years ago)
Author:
eugene
Message:

fix psMatrixSVD to allocate the output vectors if needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psLib/src/math/psMatrix.c

    r26344 r26346  
    11511151// dimensionality of A.
    11521152// XXX there is no error handling for the gsl functions (anywhere in psMatrix.c)
    1153 bool psMatrixSVD(psImage *U, psVector *w, psImage *V, const psImage *A)
     1153bool psMatrixSVD(psImage **U, psVector **w, psImage **V, const psImage *A)
    11541154{
    11551155    // Error checks  Missing one for eval
     1156    PS_ASSERT_PTR_NON_NULL(*U, false);
     1157    PS_ASSERT_PTR_NON_NULL(*w, false);
     1158    PS_ASSERT_PTR_NON_NULL(*V, false);
    11561159    PS_ASSERT_GENERAL_IMAGE_NON_NULL(A, false);
    11571160    PS_CHECK_POINTERS(A, evec, false);
     
    11671170    int numCols = A->numCols;
    11681171
    1169     U = psImageRecycle(U,  numCols, numRows, A->type.type);
    1170     V = psImageRecycle(V,  numCols, numCols, A->type.type);
    1171     w = psVectorRecycle(w, numCols, A->type.type);
     1172    *U = psImageRecycle(*U,  numCols, numRows, A->type.type);
     1173    *V = psImageRecycle(*V,  numCols, numCols, A->type.type);
     1174    *w = psVectorRecycle(*w, numCols, A->type.type);
    11721175
    11731176    gsl_matrix *Agsl = gsl_matrix_alloc(numRows, numCols);
     
    11831186
    11841187    // Copy GSL matrix data to psImage data
    1185     matrixGSLtoPS(V, Vgsl);
    1186     matrixGSLtoPS(U, Agsl);  // gsl_linalg_SV_decomp replaces A with U
    1187     vectorGSLtoPS(S, Sgsl);
     1188    matrixGSLtoPS(*V, Vgsl);
     1189    matrixGSLtoPS(*U, Agsl);  // gsl_linalg_SV_decomp replaces A with U
     1190    vectorGSLtoPS(*w, Sgsl);
    11881191
    11891192    // Free GSL data
    1190     gsl_matrix_free(A);
    1191     gsl_matrix_free(V);
    1192     gsl_vector_free(S);
     1193    gsl_matrix_free(Agsl);
     1194    gsl_matrix_free(Vgsl);
     1195    gsl_vector_free(Sgsl);
    11931196    gsl_vector_free(work);
    11941197
Note: See TracChangeset for help on using the changeset viewer.