IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 6, 2004, 2:06:06 PM (22 years ago)
Author:
desonia
Message:

another attempt to get astyle to get it right.

File:
1 edited

Legend:

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

    r1406 r1407  
     1
    12/** @file  psMatrix.c
    23 *
     
    2021 *  @author Ross Harman, MHPCC
    2122 *   
    22  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    23  *  @date $Date: 2004-08-06 22:34:05 $
     23 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     24 *  @date $Date: 2004-08-07 00:06:06 $
    2425 *
    2526 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2728
    2829/******************************************************************************/
     30
    2931/*  INCLUDE FILES                                                             */
     32
    3033/******************************************************************************/
    3134#include <string.h>
     
    4245
    4346/******************************************************************************/
     47
    4448/*  DEFINE STATEMENTS                                                         */
     49
    4550/******************************************************************************/
    4651
     
    4853
    4954/******************************************************************************/
     55
    5056/*  TYPE DEFINITIONS                                                          */
     57
    5158/******************************************************************************/
    5259
     
    5461
    5562/*****************************************************************************/
     63
    5664/*  GLOBAL VARIABLES                                                         */
     65
    5766/*****************************************************************************/
    5867
     
    6069
    6170/*****************************************************************************/
     71
    6272/*  FILE STATIC VARIABLES                                                    */
     73
    6374/*****************************************************************************/
    6475
     
    6677
    6778/*****************************************************************************/
     79
    6880/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
     81
    6982/*****************************************************************************/
    7083
     
    142155
    143156/*****************************************************************************/
     157
    144158/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    145 /*****************************************************************************/
    146 
    147 psImage *psMatrixLUD(psImage *outImage, psVector *outPerm, psImage *inImage)
     159
     160/*****************************************************************************/
     161
     162psImage *psMatrixLUD(psImage * outImage, psVector * outPerm, psImage * inImage)
    148163{
    149164    int signum = 0;
     
    169184    numRows = inImage->numRows;
    170185    numCols = inImage->numCols;
    171     arraySize = PSELEMTYPE_SIZEOF(inImage->type.type)*numRows*numCols;
     186    arraySize = PSELEMTYPE_SIZEOF(inImage->type.type) * numRows * numCols;
    172187
    173188    // Initialize GSL data
     
    190205}
    191206
    192 psVector *psMatrixLUSolve(psVector *outVector, const psImage *inImage, const psVector *inVector, const
    193                           psVector *inPerm)
     207psVector *psMatrixLUSolve(psVector * outVector, const psImage * inImage, const psVector * inVector, const
     208                          psVector * inPerm)
    194209{
    195210    int arraySize = 0;
     
    219234    numRows = inImage->numRows;
    220235    numCols = inImage->numCols;
    221     arraySize = PSELEMTYPE_SIZEOF(inImage->type.type)*numRows*numCols;
     236    arraySize = PSELEMTYPE_SIZEOF(inImage->type.type) * numRows * numCols;
    222237
    223238    // Initialize GSL data
     
    243258}
    244259
    245 psImage *psMatrixInvert(psImage *outImage, const psImage *inImage, float *restrict det)
     260psImage *psMatrixInvert(psImage * outImage, const psImage * inImage, float *restrict det)
    246261{
    247262    int signum = 0;
     
    254269
    255270    // Error checks
    256     if(det == NULL) {
     271    if (det == NULL) {
    257272        psError(__func__, "Invalid operation: determinant argument is NULL.");
    258273        return outImage;
     
    269284    numRows = inImage->numRows;
    270285    numCols = inImage->numCols;
    271     arraySize = PSELEMTYPE_SIZEOF(inImage->type.type)*numRows*numCols;
     286    arraySize = PSELEMTYPE_SIZEOF(inImage->type.type) * numRows * numCols;
    272287
    273288    // Allocate GSL structs
     
    297312}
    298313
    299 float* psMatrixDeterminant(const psImage *restrict inImage)
     314float *psMatrixDeterminant(const psImage * restrict inImage)
    300315{
    301316    int signum = 0;
     
    315330    numRows = inImage->numRows;
    316331    numCols = inImage->numCols;
    317     arraySize = PSELEMTYPE_SIZEOF(inImage->type.type)*numRows*numCols;
     332    arraySize = PSELEMTYPE_SIZEOF(inImage->type.type) * numRows * numCols;
    318333
    319334    // Allocate GSL structs
     
    328343
    329344    // Calculate determinant
    330     det = (float*)psAlloc(sizeof(float));
     345    det = (float *)psAlloc(sizeof(float));
    331346    gsl_linalg_LU_decomp(lu, perm, &signum);
    332347    *det = (float)gsl_linalg_LU_det(lu, signum);
     
    339354}
    340355
    341 psImage* psMatrixMultiply(psImage *outImage, psImage *inImage1, psImage *inImage2)
     356psImage *psMatrixMultiply(psImage * outImage, psImage * inImage1, psImage * inImage2)
    342357{
    343358    int arraySize = 0;
     
    364379    numRows = inImage1->numRows;
    365380    numCols = inImage1->numCols;
    366     arraySize = PSELEMTYPE_SIZEOF(outImage->type.type)*numRows*numCols;
     381    arraySize = PSELEMTYPE_SIZEOF(outImage->type.type) * numRows * numCols;
    367382
    368383    // Initialize GSL data
     
    381396}
    382397
    383 psImage* psMatrixTranspose(psImage *outImage, const psImage *inImage)
     398psImage *psMatrixTranspose(psImage * outImage, const psImage * inImage)
    384399{
    385400    int arraySize = 0;
     
    400415    numRows = inImage->numRows;
    401416    numCols = inImage->numCols;
    402     arraySize = PSELEMTYPE_SIZEOF(inImage->type.type)*numRows*numCols;
     417    arraySize = PSELEMTYPE_SIZEOF(inImage->type.type) * numRows * numCols;
    403418
    404419    // Initialize GSL data
     
    418433}
    419434
    420 psImage *psMatrixEigenvectors(psImage *outImage, psImage *inImage)
     435psImage *psMatrixEigenvectors(psImage * outImage, psImage * inImage)
    421436{
    422437    int numRows = 0;
     
    462477}
    463478
    464 psVector *psMatrixToVector(psVector *outVector, psImage *inImage)
     479psVector *psMatrixToVector(psVector * outVector, psImage * inImage)
    465480{
    466481    int size = 0;
     
    471486    PS_CHECK_SIZE_IMAGE(inImage, outVector);
    472487
    473     if(inImage->numRows == 1) {
     488    if (inImage->numRows == 1) {
    474489        // Create transposed row vector
    475490        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numCols, inImage->type.type);
    476491        outVector->type.dimen = PS_DIMEN_TRANSV;
    477     } else
    478         if(inImage->numCols == 1) {
    479             // Create non-transposed column vector
    480             PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
    481         } else {
    482             psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows,
    483                     inImage->numCols);
    484             return outVector;
    485         }
     492    } else if (inImage->numCols == 1) {
     493        // Create non-transposed column vector
     494        PS_CHECK_ALLOC_VECTOR(outVector, inImage->numRows, inImage->type.type);
     495    } else {
     496        psError(__func__, "Image does not have dim with 1 col or 1 row: (%d x %d).", inImage->numRows,
     497                inImage->numCols);
     498        return outVector;
     499    }
    486500
    487501    PS_CHECK_NULL_VECTOR(outVector, outVector);
    488502
    489 
    490503    // More checks
    491     if(outVector->type.dimen == PS_DIMEN_VECTOR) {
     504    if (outVector->type.dimen == PS_DIMEN_VECTOR) {
    492505        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
    493506
    494         if(outVector->n == 0) {
     507        if (outVector->n == 0) {
    495508            outVector->n = inImage->numRows;
    496509        }
    497510
    498         if(outVector->n != inImage->numRows) {
     511        if (outVector->n != inImage->numRows) {
    499512            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numRows, outVector->n);
    500513            return outVector;
    501514        }
    502515
    503         size = PSELEMTYPE_SIZEOF(inImage->type.type)*inImage->numRows;
    504 
    505     } else
    506         if(outVector->type.dimen == PS_DIMEN_TRANSV) {
    507             PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, outVector);
    508 
    509             if(outVector->n == 0) {
    510                 outVector->n = inImage->numCols;
    511             }
    512 
    513             if(outVector->n != inImage->numCols) {
    514                 psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n);
    515                 return outVector;
    516             }
    517 
    518             size = PSELEMTYPE_SIZEOF(inImage->type.type)*inImage->numCols;
     516        size = PSELEMTYPE_SIZEOF(inImage->type.type) * inImage->numRows;
     517
     518    } else if (outVector->type.dimen == PS_DIMEN_TRANSV) {
     519        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, outVector);
     520
     521        if (outVector->n == 0) {
     522            outVector->n = inImage->numCols;
    519523        }
    520524
     525        if (outVector->n != inImage->numCols) {
     526            psError(__func__, "Image and vector sizes differ: (%d vs %d).", inImage->numCols, outVector->n);
     527            return outVector;
     528        }
     529
     530        size = PSELEMTYPE_SIZEOF(inImage->type.type) * inImage->numCols;
     531    }
     532
    521533    memcpy(outVector->data.V, inImage->data.V[0], size);
    522534
     
    524536}
    525537
    526 psImage *psVectorToMatrix(psImage *outImage, psVector *inVector)
     538psImage *psVectorToMatrix(psImage * outImage, psVector * inVector)
    527539{
    528540    int size = 0;
     
    531543    PS_CHECK_NULL_VECTOR(inVector, outImage);
    532544
    533     if(inVector->type.dimen == PS_DIMEN_VECTOR) {
     545    if (inVector->type.dimen == PS_DIMEN_VECTOR) {
    534546        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage);
    535547        PS_CHECK_SIZE_VECTOR(inVector, outImage);
    536548        PS_CHECK_ALLOC_IMAGE(outImage, 1, inVector->n, PS_TYPE_F64)
    537 
    538549        // More checks for PS_DIMEN_VECTOR
    539         if(outImage->numCols > 1) {
     550        if (outImage->numCols > 1) {
    540551            psError(__func__, "Image has more than 1 column: numCols = %d.", outImage->numCols);
    541552            return outImage;
    542         } else
    543             if(outImage->numRows != inVector->n) {
    544                 psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n);
    545                 return outImage;
    546             }
    547 
    548         size = PSELEMTYPE_SIZEOF(outImage->type.type)*outImage->numRows;
    549 
    550     } else
    551         if(inVector->type.dimen == PS_DIMEN_TRANSV) {
    552             PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
    553             PS_CHECK_SIZE_VECTOR(inVector, outImage);
    554             PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)
    555 
    556             // More checks for PS_DIMEN_TRANSV
    557             if(outImage->numRows > 1) {
    558                 psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows);
    559                 return outImage;
    560             } else
    561                 if(outImage->numCols != inVector->n) {
    562                     psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n);
    563                     return outImage;
    564                 }
    565 
    566             size = PSELEMTYPE_SIZEOF(outImage->type.type)*outImage->numCols;
     553        } else if (outImage->numRows != inVector->n) {
     554            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numRows, inVector->n);
     555            return outImage;
    567556        }
     557
     558        size = PSELEMTYPE_SIZEOF(outImage->type.type) * outImage->numRows;
     559
     560    } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
     561        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
     562        PS_CHECK_SIZE_VECTOR(inVector, outImage);
     563        PS_CHECK_ALLOC_IMAGE(outImage, inVector->n, 1, PS_TYPE_F64)
     564        // More checks for PS_DIMEN_TRANSV
     565        if (outImage->numRows > 1) {
     566            psError(__func__, "Image has more than 1 row: numRows = %d.", outImage->numRows);
     567            return outImage;
     568        } else if (outImage->numCols != inVector->n) {
     569            psError(__func__, "Image and vector sizes differ: (%d vs %d).", outImage->numCols, inVector->n);
     570            return outImage;
     571        }
     572
     573        size = PSELEMTYPE_SIZEOF(outImage->type.type) * outImage->numCols;
     574    }
    568575
    569576    PS_CHECK_NULL_IMAGE(outImage, outImage);
     
    574581    return outImage;
    575582}
    576 
Note: See TracChangeset for help on using the changeset viewer.