#include <config/config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "abort_prog.h"
#include "array_util.h"
#include "testvec.h"
#include "rand_util.h"
#include "parse_opts.h"
Routines to display parameter values on stderr. | |
----------------------------------------------------- | |
static void | DisplayValue (const char *name, oski_value_t x) |
static void | DisplayMatop (const char *matname, oski_matop_t op) |
static void | DisplayVecView (const char *name, const oski_vecview_t x) |
static void | DisplayATAop (const char *matname, oski_ataop_t op) |
Defines | |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
Macro to return the minimum value of a pair. | |
Typedefs | |
typedef int(* | filter_funcpt )(oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Defines a 'non-zero filter' function type. | |
Functions | |
oski_vecview_t | testvec_Create (oski_index_t len, oski_index_t num_vecs, oski_storage_t orient, int use_minstride) |
Allocate a dense 2-D array, fill it with random values, and return it wrapped in a newly allocated vector view object. | |
size_t | testvec_CalcDataSize (const oski_vecview_t x) |
Based on its storage orientation and stride, returns the minimum size (in elements) of the underlying storage array. | |
oski_vecview_t | testvec_Clone (const oski_vecview_t x) |
Clone an object created using testvec_Create(). | |
void | testvec_Destroy (oski_vecview_t x) |
Destroy a test vector created via testvec_Create(). | |
void | testmat_GenDenseCSR (oski_index_t m, oski_index_t n, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Generates a dense, non-symmetric matrix in sparse CSR format. | |
size_t | testmat_ChooseDim (size_t nz_volume, size_t elem_size) |
Select the dimension for a square, dense matrix whose size in Bytes exceeds nz_volume. | |
size_t | ChooseDivisible (size_t n, size_t d) |
Returns the smallest integer such that . | |
void | testmat_ChangeSizeDenseCSR (oski_index_t m_new, oski_index_t n_new, oski_index_t *ptr, oski_index_t *ind) |
Changes the dimensions (and pattern) of a previously allocated dense CSR test matrix. | |
void | testmat_ChangeSizeDenseTriCSR (oski_index_t n_new, int make_lower, int cond_for_trisolve, oski_index_t *ptr, oski_index_t *ind, oski_value_t *val) |
Changes the pattern of a previously allocated dense CSR test matrix to a dense triangular pattern. | |
static oski_index_t | gcd (oski_index_t a, oski_index_t b) |
static oski_index_t | lcm (oski_index_t a, oski_index_t b) |
void | testmat_GenBlockedBandedCSR (oski_index_t k_min, oski_index_t row_min, oski_index_t r, oski_index_t c, oski_index_t *p_n, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Generates a matrix with a banded shape, where each row contains dense blocks of a given size. | |
static int | CheckMatMultVectors (const oski_matrix_t A, const oski_vecview_t x, const oski_vecview_t y0, const oski_vecview_t y1) |
Returns 0 if two distinct computations of a matrix-vector product are numerical 'equal' within some reasonable error bound, or ERR_WRONG_ANS otherwise. | |
int | check_MatMult_instance (const oski_matrix_t A0, const oski_matrix_t A1, oski_matop_t opA, oski_value_t alpha, const oski_vecview_t x, oski_value_t beta, oski_vecview_t y0) |
Check an instance of matrix-vector multiply. | |
int | check_MatTrisolve_instance (const oski_matrix_t A0, const oski_matrix_t A1, oski_matop_t opA, oski_value_t alpha, const oski_vecview_t b) |
Check an instance of sparse triangular solve. | |
int | check_MatMultAndMatTransMult_instance (const oski_matrix_t A0, const oski_matrix_t A1, oski_value_t alpha, const oski_vecview_t x, oski_value_t beta, oski_vecview_t y0, oski_matop_t opA, oski_value_t omega, const oski_vecview_t w, oski_value_t zeta, oski_vecview_t z0) |
Check and instance of simultaneous multiplication by sparse and . | |
int | check_MatTransMatMult_instance (const oski_matrix_t A0, const oski_matrix_t A1, oski_ataop_t opA, oski_value_t alpha, const oski_vecview_t x, oski_value_t beta, oski_vecview_t y0, oski_vecview_t t0) |
Check an instance of sparse . | |
static int | filter_valid (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
A filter that allows any valid entry to be a non-zero. | |
static int | filter_strictly_lower_tri (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filter for a strictly lower triangular matrix. | |
static int | filter_strictly_upper_tri (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filter for a strictly upper triangular matrix. | |
static int | filter_diagonal (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filter for diagonal entries. | |
static int | filter_offdiag (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filter for off-diagonal entries. | |
static int | filter_lower_tri (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filters a lower triangular matrix. | |
static int | filter_upper_tri (oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j) |
Filters a upper triangular matrix. | |
static void | create_rawmat_csr (oski_index_t m, oski_index_t n, oski_index_t min_nnz_row, oski_index_t max_nnz_row, filter_funcpt filter, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Create a raw CSR matrix, using 0-based indices, with a bounded number of non-zeros per row. | |
static void | adjust_base (oski_index_t *array, oski_index_t len, oski_index_t b) |
Given an array of index pointers, adjust the base index. | |
static void | expand_rawmat_csr (oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val, oski_index_t m, oski_index_t n, oski_inmatprop_t shape) |
Expands a raw, 0-based CSR matrix into a full-storage 0-based CSR matrix if shape == MAT_SYMM_FULL or MAT_HERM_FULL. | |
oski_matrix_t | testmat_GenRandomCSR (oski_index_t m, oski_index_t n, oski_index_t min_nnz_row, oski_index_t max_nnz_row, oski_inmatprop_t shape, int implicit_diag, int index_base, oski_copymode_t copymode, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Create a raw matrix pattern and matrix object corresponding to the caller-specified dimensions and shape. | |
static void | GetShapeBounds (oski_inmatprop_t shape, oski_index_t m, oski_index_t i, oski_index_t *p_j_min, oski_index_t *p_j_max) |
Returns the minimum and maximum non-zero column index for a given row of an m x m triangular matrix with the prescribed shape (lower or upper triangular). | |
void | testmat_GenTriCSC (oski_index_t m, oski_index_t max_nnz_row, oski_inmatprop_t shape, int is_unitdiag, int is_sorted, int indbase, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Generates a random, well-conditioned sparse triangular matrix in CSC format with the prescribed attributes for testing triangular solve. | |
void | testmat_GenTriCSR (oski_index_t m, oski_index_t max_nnz_row, oski_inmatprop_t shape, int is_unitdiag, int is_sorted, int indbase, oski_index_t **p_ptr, oski_index_t **p_ind, oski_value_t **p_val) |
Generates a random, well-conditioned sparse triangular matrix in CSR format with the prescribed attributes for testing triangular solve. |
|
Defines a 'non-zero filter' function type. A non-zero filter function f(m, n, i, j) returns 1 if (i, j) is an 'acceptable' non-zero for a matrix of size m x n, or 0 otherwise. The indices (i, j) are assume to be 1-based. For instance, the following is a composition of two filter functions that can be used to generate a lower triangular matrix:
int filter_any( oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j ) { // Ensures valid indices return (1 <= i) && (i <= m) && (1 <= j) && (j <= n); } int filter_lowertri( oski_index_t m, oski_index_t n, oski_index_t i, oski_index_t j ) { return filter_any(m, n, i, j) && j <= i; } |
|
Check an instance of matrix-vector multiply. If the calculation is merely incorrect, then this routine prints a message and returns ERR_WRONG_ANS. |
|
Check and instance of simultaneous multiplication by sparse and . If the calculation is merely incorrect, then this routine prints a message and returns ERR_WRONG_ANS. |
|
Check an instance of sparse . If the calculation is merely incorrect, then this routine prints a message and returns ERR_WRONG_ANS. |
|
Check an instance of sparse triangular solve. If the calculation is merely incorrect, then this routine prints a message and returns ERR_WRONG_ANS. |
|
Returns 0 if two distinct computations of a matrix-vector product are numerical 'equal' within some reasonable error bound, or ERR_WRONG_ANS otherwise.
|
|
Create a raw CSR matrix, using 0-based indices, with a bounded number of non-zeros per row. This routine aborts the program if a memory error occurs. |
|
Expands a raw, 0-based CSR matrix into a full-storage 0-based CSR matrix if shape == MAT_SYMM_FULL or MAT_HERM_FULL.
|
|
Returns the minimum and maximum non-zero column index for a given row of an m x m triangular matrix with the prescribed shape (lower or upper triangular).
|
|
Changes the dimensions (and pattern) of a previously allocated dense CSR test matrix.
|
|
Changes the pattern of a previously allocated dense CSR test matrix to a dense triangular pattern.
|
|
Select the dimension for a square, dense matrix whose size in Bytes exceeds nz_volume.
|
|
Generates a matrix with a banded shape, where each row contains dense blocks of a given size.
|
|
Generates a dense, non-symmetric matrix in sparse CSR format.
|
|
Create a raw matrix pattern and matrix object corresponding to the caller-specified dimensions and shape.
|
|
Generates a random, well-conditioned sparse triangular matrix in CSR format with the prescribed attributes for testing triangular solve.
|
|
Allocate a dense 2-D array, fill it with random values, and return it wrapped in a newly allocated vector view object.
|