Exemple #1
0
void lcp_nsgs_SBM_buildLocalProblem(int rowNumber, const SparseBlockStructuredMatrix* const blmat, LinearComplementarityProblem* local_problem, double* q, double* z)
{

  assert(blmat->blocksize0[rowNumber] > 0);

  /* Position in vector blmat->block of the required diagonal block */
  int diagPos = getDiagonalBlockPos(blmat, rowNumber);
  /* Gets diagonal block = MLocal  */
  local_problem->M->matrix0 = blmat->block[diagPos];
  local_problem->size = blmat->blocksize0[rowNumber];
  int pos = 0;
  if (rowNumber != 0)
  {
    local_problem->size -= blmat->blocksize0[rowNumber - 1];
    pos =  blmat->blocksize0[rowNumber - 1];
  }

  local_problem->M->size0 = local_problem->size;
  local_problem->M->size1 = local_problem->size;

  /* Computes qLocal */
  /* qLocal = q[rowNumber] + sum (rowM.z),
     sum over all non-diagonal blocks, rowM being the current
     row of blocks of M
  */
  cblas_dcopy_msan(local_problem->size, &q[pos], 1, local_problem->q, 1);
  rowProdNoDiagSBM(blmat->blocksize0[blmat->blocknumber0 - 1], local_problem->size, rowNumber, blmat, z, local_problem->q, 0);

}
Exemple #2
0
void rowProdNoDiag(int sizeX, int sizeY, int currentRowNumber, const NumericsMatrix* A, const double* const x, double* y, int init)
{

    assert(A);
    assert(x);
    assert(y);
    assert(A->size0 >= sizeY);
    assert(A->size1 == sizeX);

    /* Checks storage type */
    int storage = A->storageType;


    /* double* storage */
    if (storage == 0)
    {
        double * xSave = (double*) malloc(sizeY * sizeof(double));
        double * xx = (double *)x; /*because of const*/
        for (int i = 0; i < sizeY; i++)
        {
            xSave[i] = x[currentRowNumber + i];
            xx[currentRowNumber + i] = 0;
        }
        double * MM = A->matrix0 + currentRowNumber;
        int incx = A->size0;
        int incy = 1;
        if (init)
        {
            for (int i = 0; i < sizeY; i++)
                y[i] = 0;
        }
        for (int i = 0; i < sizeY; i++)
        {
            y[i] += cblas_ddot(A->size0 , MM + i , incx , x , incy);
        }
        for (int i = 0; i < sizeY; i++)
        {
            xx[currentRowNumber + i] = xSave[i];
        }
        free(xSave);

    }
    else if (storage == 1)
        rowProdNoDiagSBM(sizeX, sizeY, currentRowNumber, A->matrix1, x, y, init);
    else
    {
        fprintf(stderr, "Numerics, NumericsMatrix, product matrix - vector rowProdNoDiag(A,x,y) failed, unknown storage type for A.\n");
        exit(EXIT_FAILURE);
    }
}