Ejemplo n.º 1
0
inline
void ColumnView(sparse_matrix_t<T>& A, sparse_matrix_t<T>& B, int j, int width) {
    const int *bindptr = B.indptr();
    const int *bindices = B.indices();
    double *bvalues = B.values();

    int start = bindptr[j];
    int *indptr = new int[width + 1];
    for (int i = 0; i <= width; i++)
        indptr[i] = bindptr[j + i] - start;
    const int *indices = bindices + start;
    double *values = bvalues + start;

    A.attach(indptr, indices, values, indptr[width], A.height(), width,
        true, false, false);
}
Ejemplo n.º 2
0
inline void Gemv(El::Orientation oA,
    T alpha, const sparse_matrix_t<T>& A, const El::Matrix<T>& x,
    T beta, El::Matrix<T>& y) {
    // TODO verify sizes etc.

    const int* indptr = A.indptr();
    const int* indices = A.indices();
    const double *values = A.locked_values();
    double *yd = y.Buffer();
    const double *xd = x.LockedBuffer();

    int n = A.width();

    if (oA == El::NORMAL) {
        El::Scale(beta, y);

#       if SKYLARK_HAVE_OPENMP
#       pragma omp parallel for
#       endif
        for(int col = 0; col < n; col++) {
            T xv = alpha * xd[col];
            for (int j = indptr[col]; j < indptr[col + 1]; j++) {
                     int row = indices[j];
                     T val = values[j];
                     yd[row] += val * xv;
                 }
        }

    } else {

#       if SKYLARK_HAVE_OPENMP
#       pragma omp parallel for
#       endif
        for(int col = 0; col < n; col++) {
            double yv = beta * yd[col];
            for (int j = indptr[col]; j < indptr[col + 1]; j++) {
                     int row = indices[j];
                     T val = values[j];
                     yv += alpha * val * xd[row];
                 }
            yd[col] = yv;
        }

    }
}
Ejemplo n.º 3
0
int Height(const sparse_matrix_t<T>& A) {
    return A.height();
}
Ejemplo n.º 4
0
int Width(const sparse_matrix_t<T>& A) {
    return A.width();
}