|
BeBOP Optimized Sparse Kernel Interface Library
1.0.1h
|
Get/set matrix values. More...
#include <assert.h>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <oski/oski.h>#include "abort_prog.h"#include "testvec.h"#include "rand_util.h"Defines | |
| #define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
| Returns the larger of two input arguments. | |
| #define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
| Returns the smaller of two input arguments. | |
Functions | |
| static void | scatter (const oski_index_t *ind, const oski_value_t *val, oski_index_t len, oski_index_t index_base, oski_value_t *dest) |
| Scatters the non-zero values in a compressed sparse vector representation into a dense (full) vector. | |
| static void | scatter_zero (const oski_index_t *ind, oski_index_t len, oski_index_t index_base, oski_value_t *dest) |
| Scatters the value '0' into a dense vector from a compressed sparse index vector. | |
| static void | check_values (const oski_value_t a, const oski_value_t b, oski_index_t row, oski_index_t col) |
| Looks at the absolute difference in magnitude between two scalar values, and aborts the program if they exceed (constant) * (machine epsilon). | |
| static void | compare_row (const oski_matrix_t A, oski_index_t row, const oski_index_t *indp, oski_index_t len, oski_index_t index_base, const oski_value_t *full_row) |
| Check that all the non-zeros physically stored in the raw CSR representation are correctly returned by oski_GetMatEntry(). | |
| static void | compare_row_transimage (const oski_matrix_t A, oski_index_t row, const oski_index_t *indp, oski_index_t len, oski_inmatprop_t shape, oski_index_t index_base, const oski_value_t *full_row) |
| Given a symmetric or Hermitian matrix for which A(i,j) is stored, checks that calling oski_GetMatEntry() to retrieve the (j, i) element returns the correct value. | |
| static void | spot_check_row_read (const oski_matrix_t A, oski_index_t row, oski_index_t n, const oski_index_t *indp, oski_index_t len, oski_inmatprop_t shape, oski_index_t index_base, const oski_value_t *full_row) |
| Randomly selects entries from the specified row of the given matrix and confirms that they correspond to the correct raw representation value. | |
| static void | expand_full_row (const oski_index_t *indp, const oski_value_t *valp, oski_index_t len, oski_index_t index_base, oski_index_t implicit_diag, oski_index_t row, oski_index_t max_row_len, oski_value_t *full_row) |
| Expands a sparse vector to a dense vector representation. | |
| static void | zero_full_row (const oski_index_t *indp, oski_index_t len, oski_index_t index_base, oski_index_t implicit_diag, oski_index_t row, oski_index_t max_row_len, oski_value_t *full_row) |
| Zeros the elements of a dense vector (full row) representation based on the sparse pattern. | |
| static void | check_case_row_read (const oski_matrix_t A, oski_index_t row, const oski_index_t *ptr, const oski_index_t *ind, const oski_value_t *val, oski_index_t m, oski_index_t n, oski_inmatprop_t shape, int implicit_diag, int index_base, oski_value_t *full_row) |
| Performs a number of correctness tests related to reading entries in a given row of a matrix and its raw CSR representation. | |
| static void | check_row_write (oski_matrix_t A, oski_matrix_t A_copy, oski_index_t row, const oski_index_t *indp, oski_index_t len, oski_index_t index_base, oski_value_t *full_row) |
| Checks that all stored values in a given row are changed correctly. | |
| static void | check_case_row_write (oski_matrix_t A, oski_matrix_t A_copy, oski_index_t row, const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, oski_inmatprop_t shape, int implicit_diag, int index_base, oski_value_t *full_row) |
| Performs a number of correctness tests related to modifying entries in a given row of a matrix and its raw CSR representation. | |
| static const char * | tostring_shape (oski_inmatprop_t shape) |
| static void | run_read_write_test_battery (oski_matrix_t A, oski_matrix_t A_copy, const oski_index_t *ptr, const oski_index_t *ind, oski_value_t *val, oski_index_t m, oski_index_t n, oski_inmatprop_t shape, int implicit_diag, int index_base) |
| Given a matrix object and its corresponding raw CSR representation, executes a battery of tests to exercise oski_GetMatEntry() and oski_SetMatEntry(). | |
| static void | check_case (oski_index_t m, oski_index_t n, oski_index_t max_nnz_row, oski_inmatprop_t shape, int implicit_diag, int index_base, const char *xform) |
| static void | check_cases (oski_index_t max_rows, oski_index_t max_cols, oski_index_t max_nnz_row, const char *xform) |
| Checks oski_GetMatEntry() and oski_SetMatEntry() for a variety of randomly generated input matrices. | |
| int | main (int argc, char *argv[]) |
Get/set matrix values.
| #define MAX | ( | a, | |
| b | |||
| ) | ((a) > (b) ? (a) : (b)) |
Returns the larger of two input arguments.
Referenced by check_values().
| #define MIN | ( | a, | |
| b | |||
| ) | ((a) < (b) ? (a) : (b)) |
Returns the smaller of two input arguments.
| static void check_case_row_read | ( | const oski_matrix_t | A, |
| oski_index_t | row, | ||
| const oski_index_t * | ptr, | ||
| const oski_index_t * | ind, | ||
| const oski_value_t * | val, | ||
| oski_index_t | m, | ||
| oski_index_t | n, | ||
| oski_inmatprop_t | shape, | ||
| int | implicit_diag, | ||
| int | index_base, | ||
| oski_value_t * | full_row | ||
| ) | [static] |
Performs a number of correctness tests related to reading entries in a given row of a matrix and its raw CSR representation.
full_row is a temporary storage buffer of length at least 'n'. It must be initialized to zero, and on return from this routine, will be returned to a state of containing all zeros.
References compare_row(), compare_row_transimage(), expand_full_row(), INVALID_MAT, spot_check_row_read(), and zero_full_row().
Referenced by run_read_write_test_battery().
| static void check_case_row_write | ( | oski_matrix_t | A, |
| oski_matrix_t | A_copy, | ||
| oski_index_t | row, | ||
| const oski_index_t * | ptr, | ||
| const oski_index_t * | ind, | ||
| oski_index_t | m, | ||
| oski_index_t | n, | ||
| oski_inmatprop_t | shape, | ||
| int | implicit_diag, | ||
| int | index_base, | ||
| oski_value_t * | full_row | ||
| ) | [static] |
Performs a number of correctness tests related to modifying entries in a given row of a matrix and its raw CSR representation.
full_row is a temporary storage buffer of length at least 'n'. It must be initialized to zero, and on return from this routine, will be returned to a state of containing all zeros.
References ABORT, check_row_write(), ERR_WRONG_ANS, MAT_TRI_LOWER, MAT_TRI_UPPER, oski_HandleErrorDefault(), oski_SetErrorHandler(), and zero_full_row().
Referenced by run_read_write_test_battery().
| static void check_row_write | ( | oski_matrix_t | A, |
| oski_matrix_t | A_copy, | ||
| oski_index_t | row, | ||
| const oski_index_t * | indp, | ||
| oski_index_t | len, | ||
| oski_index_t | index_base, | ||
| oski_value_t * | full_row | ||
| ) | [static] |
Checks that all stored values in a given row are changed correctly.
Leaves new values in full_row.
References ABORT, check_values(), INVALID_MAT, and VAL_ASSIGN.
Referenced by check_case_row_write().
| static void expand_full_row | ( | const oski_index_t * | indp, |
| const oski_value_t * | valp, | ||
| oski_index_t | len, | ||
| oski_index_t | index_base, | ||
| oski_index_t | implicit_diag, | ||
| oski_index_t | row, | ||
| oski_index_t | max_row_len, | ||
| oski_value_t * | full_row | ||
| ) | [static] |
Expands a sparse vector to a dense vector representation.
Assumes indp has base given by index_base, but that row is always 1-based.
References scatter(), and VAL_SET_ONE.
Referenced by check_case_row_read().
| static void scatter | ( | const oski_index_t * | ind, |
| const oski_value_t * | val, | ||
| oski_index_t | len, | ||
| oski_index_t | index_base, | ||
| oski_value_t * | dest | ||
| ) | [static] |
Scatters the non-zero values in a compressed sparse vector representation into a dense (full) vector.
For all 0 <= k < len, sets dest[ind[k]-b] = val[k], where b is the index base for values in ind.
References VAL_INC, and VAL_SET_ZERO.
Referenced by expand_full_row().
| static void scatter_zero | ( | const oski_index_t * | ind, |
| oski_index_t | len, | ||
| oski_index_t | index_base, | ||
| oski_value_t * | dest | ||
| ) | [static] |
Scatters the value '0' into a dense vector from a compressed sparse index vector.
For all 0 <= k < len, sets dest[ind[k]-b] = 0, where b is the index base for values in ind.
References VAL_SET_ZERO.
Referenced by zero_full_row().
| static void zero_full_row | ( | const oski_index_t * | indp, |
| oski_index_t | len, | ||
| oski_index_t | index_base, | ||
| oski_index_t | implicit_diag, | ||
| oski_index_t | row, | ||
| oski_index_t | max_row_len, | ||
| oski_value_t * | full_row | ||
| ) | [static] |
Zeros the elements of a dense vector (full row) representation based on the sparse pattern.
Assumes indp has base given by index_base, but that row is always 1-based.
References scatter_zero(), and VAL_SET_ZERO.
Referenced by check_case_row_read(), and check_case_row_write().
1.7.6.1