IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 13, 2006, 2:02:47 PM (20 years ago)
Author:
Paul Price
Message:

Changing long to int to match SDRS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psSparse.c

    r7380 r7550  
    2929
    3030// allocate a sparse matrix container for Nrows, with Nelem slots allocated
    31 psSparse *psSparseAlloc(long Nrows, long Nelem)
     31psSparse *psSparseAlloc(int Nrows, int Nelem)
    3232{
    3333    psSparse *sparse = (psSparse *)psAlloc(sizeof(psSparse));
     
    5454
    5555// user should only add elements above the diagonal, but we don't check this
    56 bool psSparseMatrixElement(psSparse *sparse, long i, long j, float value)
     56bool psSparseMatrixElement(psSparse *sparse, int i, int j, float value)
    5757{
    5858    PS_ASSERT_PTR_NON_NULL(sparse, false);
     
    6262    if (i < j) {
    6363        psLogMsg(__func__, PS_LOG_WARN, "i=%ld, j=%ld refers to a sub-diagonal element; values switched.\n");
    64         long temp = i;
     64        int temp = i;
    6565        i = j;
    6666        j = temp;
     
    7878        }
    7979
    80         long k = sparse->Nelem;         // Index at which to add
     80        int k = sparse->Nelem;         // Index at which to add
    8181        sparse->Aij->data.F32[k] = value;
    8282        sparse->Si->data.S32[k]  = i;
     
    9595        }
    9696
    97         long k = sparse->Nelem;         // Index at which to add
     97        int k = sparse->Nelem;         // Index at which to add
    9898        sparse->Aij->data.F32[k] = value;
    9999        sparse->Si->data.S32[k]  = i;
     
    114114}
    115115
    116 void inline psSparseVectorElement(psSparse *sparse, long i, float value)
     116void inline psSparseVectorElement(psSparse *sparse, int i, float value)
    117117{
    118118
     
    129129    output = psVectorRecycle(output, vector->n, PS_TYPE_F32);
    130130
    131     long Nelem = 0;                     // Number of elements
    132     for (long j = 0; j < vector->n; j++) {
     131    int Nelem = 0;                     // Number of elements
     132    for (int j = 0; j < vector->n; j++) {
    133133        double F = 0;                    // Running total
    134134        while (matrix->Sj->data.S32[Nelem] == j) {
    135             long i = matrix->Si->data.S32[Nelem];
     135            int i = matrix->Si->data.S32[Nelem];
    136136            F += vector->data.F32[i] * matrix->Aij->data.F32[Nelem];
    137137            Nelem++;
     
    158158    dQ->n = output->n;
    159159
    160     for (long j = 0; j < Niter; j++) {
     160    for (int j = 0; j < Niter; j++) {
    161161        dQ = psSparseMatrixTimesVector(dQ, sparse, output);
    162         for (long i = 0; i < dQ->n; i++) {
     162        for (int i = 0; i < dQ->n; i++) {
    163163            psF32 dG = (dQ->data.F32[i] - Bfj->data.F32[i]) / Qii->data.F32[i];
    164164            if (fabs (dG) > constraint.paramDelta) {
     
    181181bool psSparseResort(psSparse *sparse)
    182182{
    183     long Nelem = sparse->Nelem;
     183    int Nelem = sparse->Nelem;
    184184
    185185    psVector *index = psVectorSortIndex(NULL, sparse->Sj); // Index key for sorting
     
    198198    tAij->n = tSi->n = tSj->n = Nelem;
    199199
    200     for (long i = 0; i < Nelem; i++) {
    201         long j = index->data.U32[i];
     200    for (int i = 0; i < Nelem; i++) {
     201        int j = index->data.U32[i];
    202202        tAij->data.F32[i] = Aij->data.F32[j];
    203203        tSi->data.S32[i]  = Si->data.S32[j];
Note: See TracChangeset for help on using the changeset viewer.