IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26190


Ignore:
Timestamp:
Nov 18, 2009, 4:35:54 PM (16 years ago)
Author:
Paul Price
Message:

Handle trivial case of nThreads == 0 or 1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceGroups.c

    r26182 r26190  
    6060    pmSourceGroups *groups = psAlloc(sizeof(pmSourceGroups)); // Groups, to return
    6161    psMemSetDeallocator(groups, (psFreeFunc)sourceGroupsFree);
     62
     63    groups->Xo = readout->image->col0;
     64    groups->Yo = readout->image->row0;
     65
     66    if (nThreads == 0 || nThreads == 1) {
     67        // Trivial case
     68        groups->Cx = groups->Cy = 1;
     69        groups->Nx = readout->image->numCols;
     70        groups->Ny = readout->image->numRows;
     71        groups->groups = psArrayAlloc(1);
     72        return groups;
     73    }
    6274
    6375    int nCells = nThreads * 2*2;        // number of cells in a single set
     
    8395    groups->Cx = Cx;
    8496    groups->Cy = Cy;
    85     groups->Xo = readout->image->col0, groups->Yo = readout->image->row0; // Offsets
    8697    groups->Nx = readout->image->numCols / (Cx*2);
    8798    groups->Ny = readout->image->numRows / (Cy*2);
     
    155166    PS_ASSERT_VECTORS_SIZE_EQUAL(x, y, NULL);
    156167
     168    int numSources = x->n;                // Number of sources
     169
    157170    // Populate the groups
    158     int numSources = x->n;                // Number of sources
    159171    long total = groups->Cx * groups->Cy; // Total size
    160172    for (int i = 0; i < groups->groups->n; i++) {
     
    167179
    168180    // Populate the cells
    169     for (int i = 0; i < numSources; i++) {
    170         int group = 0, cell = 0;        // Group and cell index for source
    171         pmSourceGroupsCoordToCell(&group, &cell, x->data.F32[i], y->data.F32[i], groups);
    172 
    173         psArray *cells = groups->groups->data[group]; // Cells for group
    174         psVector *cellSources = cells->data[cell];    // Indices of sources for cell within group
    175         psVectorAppend(cellSources, i);
    176     }
    177 
    178     return groups;
    179 }
     181    if (total == 1) {
     182        // Trivial case: Cx == Cy == 1
     183        psArray *cells = groups->groups->data[0]; // Cell
     184        psVector *cellSources = cells->data[0];   // Indices of sources for cell
     185        for (int i = 0; i < numSources; i++) {
     186            cellSources->data.S32[i] = i;
     187        }
     188    } else {
     189        for (int i = 0; i < numSources; i++) {
     190            int group = 0, cell = 0;        // Group and cell index for source
     191            pmSourceGroupsCoordToCell(&group, &cell, x->data.F32[i], y->data.F32[i], groups);
     192
     193            psArray *cells = groups->groups->data[group]; // Cells for group
     194            psVector *cellSources = cells->data[cell];    // Indices of sources for cell within group
     195            psVectorAppend(cellSources, i);
     196        }
     197    }
     198
     199    return groups;
     200}
Note: See TracChangeset for help on using the changeset viewer.