IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 20, 2005, 12:42:30 PM (21 years ago)
Author:
drobbin
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psMatrix.c

    r4160 r4321  
    2121 *  @author Robert DeSonia, MHPCC
    2222 *
    23  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    24  *  @date $Date: 2005-06-08 22:28:07 $
     23 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     24 *  @date $Date: 2005-06-20 22:42:29 $
    2525 *
    2626 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    191191    psS32 numCols = 0;
    192192    gsl_matrix *lu = NULL;
    193     gsl_permutation perm;
     193    gsl_permutation permGSL;
    194194
    195195
     
    212212
    213213    // Initialize GSL data
    214     perm.size = numCols;
     214    permGSL.size = numCols;
    215215    if (sizeof(size_t) == 4) {
    216216        *outPerm = psVectorRecycle(*outPerm, numCols, PS_TYPE_S32);
     
    225225
    226226    (*outPerm)->n = numCols;
    227     perm.data = (psPtr)((*outPerm)->data.U8);
     227    permGSL.data = (psPtr)((*outPerm)->data.U8);
    228228    lu = gsl_matrix_alloc(numRows, numCols);
    229229
     
    232232
    233233    // Calculate LU decomposition
    234     gsl_linalg_LU_decomp(lu, &perm, &signum); // N.B., uses Gaussian Elimination with partial pivoting.
     234    gsl_linalg_LU_decomp(lu, &permGSL, &signum); // N.B., uses Gaussian Elimination with partial pivoting.
    235235
    236236    // Copy GSL matrix data to psImage data
     
    298298}
    299299
    300 psImage* psMatrixInvert(psImage* outImage, const psImage* inImage, psF32 *det)
     300psImage* psMatrixInvert(psImage* outImage, const psImage* inImage, float *det)
    301301{
    302302    psS32 signum = 0;
     
    346346}
    347347
    348 psF32 *psMatrixDeterminant(const psImage* inImage)
     348float *psMatrixDeterminant(const psImage* in)
    349349{
    350350    psS32 signum = 0;
     
    357357    #define DETERMINANT_EXIT { return NULL; }
    358358    // Error checks
    359     PS_ASSERT_GENERAL_IMAGE_NON_NULL(inImage, DETERMINANT_EXIT);
    360     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, DETERMINANT_EXIT);
    361     PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(inImage, DETERMINANT_EXIT);
    362     PS_CHECK_SQUARE(inImage, DETERMINANT_EXIT);
     359    PS_ASSERT_GENERAL_IMAGE_NON_NULL(in, DETERMINANT_EXIT);
     360    PS_CHECK_DIMEN_AND_TYPE(in, PS_DIMEN_IMAGE, DETERMINANT_EXIT);
     361    PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(in, DETERMINANT_EXIT);
     362    PS_CHECK_SQUARE(in, DETERMINANT_EXIT);
    363363
    364364    // Initialize data
    365     numRows = inImage->numRows;
    366     numCols = inImage->numCols;
     365    numRows = in->numRows;
     366    numCols = in->numCols;
    367367
    368368    // Allocate GSL structs
    369369    perm = gsl_permutation_alloc(numRows);
    370370    lu = gsl_matrix_alloc(numRows, numCols);
    371     psImageToGslMatrix(lu, inImage);
     371    psImageToGslMatrix(lu, in);
    372372
    373373    // Calculate determinant
     
    480480}
    481481
    482 psImage* psMatrixEigenvectors(psImage* outImage, psImage* inImage)
     482psImage* psMatrixEigenvectors(psImage* out, psImage* in)
    483483{
    484484    psS32 numRows = 0;
     
    486486    gsl_vector *eVals = NULL;
    487487    gsl_eigen_symmv_workspace *w = NULL;
    488     gsl_matrix *out = NULL;
    489     gsl_matrix *in = NULL;
    490 
    491     #define EIGENVECTORS_CLEANUP { psFree(outImage); return NULL; }
    492     // Error checks
    493     PS_ASSERT_GENERAL_IMAGE_NON_NULL(inImage, EIGENVECTORS_CLEANUP);
    494     PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, EIGENVECTORS_CLEANUP);
    495     PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(inImage, EIGENVECTORS_CLEANUP);
    496     PS_CHECK_POINTERS(inImage, outImage, EIGENVECTORS_CLEANUP);
    497 
    498     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
     488    gsl_matrix *outGSL = NULL;
     489    gsl_matrix *inGSL = NULL;
     490
     491    #define EIGENVECTORS_CLEANUP { psFree(out); return NULL; }
     492    // Error checks
     493    PS_ASSERT_GENERAL_IMAGE_NON_NULL(in, EIGENVECTORS_CLEANUP);
     494    PS_CHECK_DIMEN_AND_TYPE(in, PS_DIMEN_IMAGE, EIGENVECTORS_CLEANUP);
     495    PS_ASSERT_GENERAL_IMAGE_NON_EMPTY(in, EIGENVECTORS_CLEANUP);
     496    PS_CHECK_POINTERS(in, out, EIGENVECTORS_CLEANUP);
     497
     498    out = psImageRecycle(out, in->numCols, in->numRows, in->type.type);
    499499
    500500    // Initialize data
    501     numRows = inImage->numRows;
    502     numCols = inImage->numCols;
    503 
    504     in = gsl_matrix_alloc(numRows, numCols);
    505     psImageToGslMatrix(in, inImage);
    506     out = gsl_matrix_alloc(numRows, numCols);
     501    numRows = in->numRows;
     502    numCols = in->numCols;
     503
     504    inGSL = gsl_matrix_alloc(numRows, numCols);
     505    psImageToGslMatrix(inGSL, in);
     506    outGSL = gsl_matrix_alloc(numRows, numCols);
    507507
    508508    // Allocate GSL structs
     
    511511
    512512    // Non-square matrices not allowed
    513     PS_CHECK_SQUARE(inImage, EIGENVECTORS_CLEANUP);
    514     PS_CHECK_SQUARE(outImage, EIGENVECTORS_CLEANUP);
     513    PS_CHECK_SQUARE(in, EIGENVECTORS_CLEANUP);
     514    PS_CHECK_SQUARE(out, EIGENVECTORS_CLEANUP);
    515515
    516516    // Calculate Eigenvalues and Eigenvectors...Eigenvalues not currently used
    517     gsl_eigen_symmv(in, eVals, out, w);
     517    gsl_eigen_symmv(inGSL, eVals, outGSL, w);
    518518
    519519    // Copy GSL matrix data to psImage data
    520     gslMatrixToPsImage(outImage, out);
     520    gslMatrixToPsImage(out, outGSL);
    521521
    522522    // Free GSL structs
    523     gsl_matrix_free(in);
    524     gsl_matrix_free(out);
     523    gsl_matrix_free(inGSL);
     524    gsl_matrix_free(outGSL);
    525525    gsl_eigen_symmv_free(w);
    526526    gsl_vector_free(eVals);
    527527
    528     return outImage;
     528    return out;
    529529}
    530530
Note: See TracChangeset for help on using the changeset viewer.