ALP User Documentation  0.8.preview
Algebraic Programming User Documentation
blas_sparse.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2021 Huawei Technologies Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
63 #ifndef _H_ALP_SPARSEBLAS_NIST
64 #define _H_ALP_SPARSEBLAS_NIST
65 
66 #include "blas_sparse_vec.h"
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
115  blas_no_trans = 0,
116  blas_trans,
117  blas_conj_trans
118 };
119 
126  blas_rowmajor,
127  blas_colmajor
128 };
129 
139 typedef void * blas_sparse_matrix;
140 
149 blas_sparse_matrix BLAS_duscr_begin( const int m, const int n );
150 
158  const double val,
159  const int row, const int col
160 );
161 
169  const int nnz,
170  const double * vals, const int * rows, const int * cols
171 );
172 
180  const int j, const int nnz,
181  const double * vals, const int * rows
182 );
183 
191  const int i, const int nnz,
192  const double * vals, const int * cols
193 );
194 
202 
209 
219 int BLAS_dusmv(
220  const enum blas_trans_type transa,
221  const double alpha, const blas_sparse_matrix A,
222  const double * const x, int incx,
223  double * const y, const int incy
224 );
225 
235 int BLAS_dusmm(
236  const enum blas_order_type order,
237  const enum blas_trans_type transa,
238  const int nrhs,
239  const double alpha, const blas_sparse_matrix A,
240  const double * B, const int ldb,
241  const double * C, const int ldc
242 );
243 
265 int EXTBLAS_dusmsv(
266  const enum blas_trans_type transa,
267  const double alpha, const blas_sparse_matrix A,
268  const EXTBLAS_TYPE( sparse_vector ) x,
269  EXTBLAS_TYPE( sparse_vector ) y
270 );
271 
295 int EXTBLAS_dusmsm(
296  const enum blas_trans_type transa,
297  const double alpha, const blas_sparse_matrix A,
298  const enum blas_trans_type transb, const blas_sparse_matrix B,
300 );
301 
314 int EXTBLAS_dusm_nz( const blas_sparse_matrix A, int * nz );
315 
332 
362 int EXTBLAS_dusm_get(
363  const blas_sparse_matrix A,
364  double * value, int * row, int * col
365 );
366 
379 
392 
402 int EXTBLAS_free();
403  // ends the SparseBLAS doxygen group
405 
406 #ifdef __cplusplus
407 } // end extern "C"
408 #endif
409 
410 #endif // end _H_ALP_SPARSEBLAS_NIST
411 
int EXTBLAS_dusmsm(const enum blas_trans_type transa, const double alpha, const blas_sparse_matrix A, const enum blas_trans_type transb, const blas_sparse_matrix B, blas_sparse_matrix C)
Performs sparse matrix–sparse matrix multiplication.
blas_sparse_matrix BLAS_duscr_begin(const int m, const int n)
Creates a handle to a new / empty sparse matrix.
int EXTBLAS_dusm_open(const blas_sparse_matrix A)
Opens a given sparse matrix for read-out.
void * blas_sparse_matrix
A sparse matrix.
Definition: blas_sparse.h:139
int BLAS_duscr_insert_row(blas_sparse_matrix A, const int i, const int nnz, const double *vals, const int *cols)
Inserts a row into A.
int BLAS_duscr_insert_entry(blas_sparse_matrix A, const double val, const int row, const int col)
Inserts a single nonzero entry into A.
blas_order_type
The supported dense storages.
Definition: blas_sparse.h:125
size_t nnz(const Vector< DataType, backend, Coords > &x) noexcept
Request the number of nonzeroes in a given vector.
Definition: io.hpp:479
int EXTBLAS_dusm_nz(const blas_sparse_matrix A, int *nz)
Retrieves the number of nonzeroes in a given, finalised, sparse matrix.
int EXTBLAS_dusm_get(const blas_sparse_matrix A, double *value, int *row, int *col)
Retrieves a sparse matrix entry.
int BLAS_dusmm(const enum blas_order_type order, const enum blas_trans_type transa, const int nrhs, const double alpha, const blas_sparse_matrix A, const double *B, const int ldb, const double *C, const int ldc)
Sparse matrix–dense matrix multiplication.
int BLAS_duscr_insert_entries(blas_sparse_matrix A, const int nnz, const double *vals, const int *rows, const int *cols)
Inserts a block of entries into A.
int EXTBLAS_dusmsv(const enum blas_trans_type transa, const double alpha, const blas_sparse_matrix A, const extblas_sparse_vector x, extblas_sparse_vector y)
Performs sparse matrix–sparse vector multiplication.
int BLAS_duscr_insert_col(blas_sparse_matrix A, const int j, const int nnz, const double *vals, const int *rows)
Inserts a column into A.
int EXTBLAS_dusm_close(const blas_sparse_matrix A)
Closes a sparse matrix read-out.
blas_trans_type
The possible transposition types.
Definition: blas_sparse.h:114
int BLAS_duscr_end(blas_sparse_matrix A)
Signals that the matrix A can now be finalised – all contents have been added.
int BLAS_dusmv(const enum blas_trans_type transa, const double alpha, const blas_sparse_matrix A, const double *const x, int incx, double *const y, const int incy)
Sparse matrix–dense vector multiplication.
This is an ALP-specific extension to the NIST Sparse BLAS standard to support sparse vectors.
int BLAS_usds(blas_sparse_matrix A)
Frees a given matrix.
int EXTBLAS_free()
This function is an implementation-specific extension of SparseBLAS that clears any buffer memory tha...
int EXTBLAS_dusm_clear(blas_sparse_matrix A)
Removes all entries from a finalised sparse matrix.