IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 1, 2005, 6:14:50 AM (21 years ago)
Author:
eugene
Message:

testing psSparse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotSparseMatrix.c

    r5652 r5653  
    11# include "psphot.h"
    2 
    3 typedef struct {
    4     psVector *Aij;
    5     psVector *Bfj;
    6     psVector *Qii;
    7     psVector *Si;
    8     psVector *Sj;
    9     int Nelem;
    10     int Nrow;
    11 } psSparse;
    12 
    13 void psphotSparseMatrixTest () {
    14 
    15     // build a sparse matrix
    16    
    17 
    18 }
    19 
    20 psVector *psSparseMatrixTimesVector (psSparse *matrix, psVector *vector) {
    21 
    22     psVector *output = psVectorAlloc (vector->n, PS_DATA_F32);
    23     psVectorInit (output, 0);
    24 
    25     Nelem = 0;
    26     for (int j = 0; j < vector->n; j++) {
    27         F = 0;
    28         while (matrix->Sj->data.S32[Nelem] == j) {
    29             i = matrix->Sj->data.S32[Nelem];
    30             F += vector->data.F32[i] * matrix->Aij->data.F32[i];
    31         }
    32         output->data.F32[j] = F;
    33     }
    34     return (output);
    35 }
    362
    373psSparse *psphotStarOverlaps (psArray *sources) {
     
    136102    return (match);
    137103}
    138 
    139 psVector *psSparseSolve (sparse) {
    140 
    141     psVector *Qii = sparse->Qii;
    142     psVector *Bfj = sparse->Bfj;
    143 
    144     psVector *Gii = psVectorCopy (NULL, Bfj);
    145     psVector *dQ = psVectorAlloc (Gii->n, PS_DATA_F32);
    146     psVector *dG = psVectorAlloc (Gii->n, PS_DATA_F32);
    147 
    148     for (int j = 0; j < 2; j++) {
    149         dQ = psSparseMatrixTimesVector (dQ, sparse, Gii);
    150         for (int i = 0; i < dG->n; i++) {
    151             dG->data.F32[i] = (dQ->data.F32[i] - Bfj->data.F32[i]) / Qii->data.F32[i];
    152             Gii->data.F32[i] -= dG->data.F32[i];
    153         }
    154     }
    155     psFree (dQ);
    156     psFree (dG);
    157    
    158     return (Gii);
    159 }
Note: See TracChangeset for help on using the changeset viewer.