#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oski/config.h>
#include <oski/common.h>
#include <oski/matrix.h>
#include <oski/CSR/module.h>
Functions | |
static int | oski_CheckIndNonDecreasing (const oski_index_t *ptr, oski_index_t m) |
Returns 1 <==> pointers are non-decreasing. | |
static int | oski_CheckIndexBase (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, oski_index_t base_index) |
Returns 1 <==> indices match the specified base. | |
static int | oski_CheckHasSortedInds (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t b, int *p_has_sorted_indices) |
Returns 1 <==> column indices are, within each row, sorted. | |
static int | oski_CheckHasUniqueInds (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, oski_index_t b, int *p_has_unique_indices) |
Returns 1 <==> column indices are, within each row, unique. | |
static int | oski_CheckIsUpperTriangular (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t b) |
Returns 0 <==> Pattern is upper triangular, and returns the offending logical row number (1-based) otherwise. | |
static int | oski_CheckIsLowerTriangular (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t b) |
Returns 0 <==> Pattern is lower triangular, and returns the offending logical row number (1-based) otherwise. | |
static int | oski_CheckPattern (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, oski_index_t b, oski_inmatprop_t pattern) |
Verify that the stored part of the CSR matrix matches the specified pattern. | |
static int | oski_CheckUnitDiagImplicit (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t b, int has_unit_diag_implicit) |
Verify whether or not matrix has an implicit unit diagonal. | |
static int | BypassCheck (void) |
Check run-time environment variable, OSKI_BYPASS_CHECK, to see whether the user wants us to skip the checking of asserted input matrix properties. | |
int | oski_CheckCSR (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, oski_inmatpropset_t *props) |
Verify that a CSR matrix representation satisfies asserted properties. |
This module implements "efficient" (i.e., O(nnz)) checks of various asserted input matrix properties.
int oski_CheckCSR | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | n, | |||
oski_inmatpropset_t * | props | |||
) |
Verify that a CSR matrix representation satisfies asserted properties.
This routine verifies that the following properties, if asserted, are true:
The implementation relies on O(nnz) algorithms to verify these properties.
If any of the properties can be strengthened to improve kernel performance, then the properties are modified to reflect the stronger assertion. There are two specific examples:
[in] | ptr | Row pointers. |
[in] | ind | Column indices. |
[in] | m | Number of rows. |
[in] | n | Number of columns. |
[in,out] | props | Asserted properties. |
References BypassCheck(), oski_inmatpropset_t::has_sorted_indices, oski_inmatpropset_t::has_unique_indices, oski_inmatpropset_t::has_unit_diag_implicit, oski_inmatpropset_t::index_base, oski_CheckHasSortedInds(), oski_CheckHasUniqueInds(), oski_CheckIndexBase(), oski_CheckIndNonDecreasing(), oski_CheckPattern(), oski_CheckUnitDiagImplicit(), oski_PrintDebugMessage(), and oski_inmatpropset_t::pattern.
static int oski_CheckHasSortedInds | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | b, | |||
int * | p_has_sorted_indices | |||
) | [static] |
Returns 1 <==> column indices are, within each row, sorted.
[in] | ptr | Row pointers. |
[in] | ind | Column indices. |
[in] | m | Number of rows. |
[in] | b | Base index. |
[in,out] | p_has_sorted_indices | Pointer to an integer which, on input, indicates the ordering property being asserted by the caller: 1 if the indices are sorted, and 0 otherwise. If equal to 0 on input but the indices are sorted, then the value pointed to is changed to 1. |
References ERR_FALSE_INMATPROP, and oski_HandleError.
Referenced by oski_CheckCSR().
static int oski_CheckHasUniqueInds | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | n, | |||
oski_index_t | b, | |||
int * | p_has_unique_indices | |||
) | [static] |
Returns 1 <==> column indices are, within each row, unique.
[in] | ptr | Row pointers. |
[in] | ind | Column indices. |
[in] | m | Number of rows. |
[in] | n | Number of columns. |
[in] | b | Base index. |
[in,out] | p_has_unique_indices | Pointer to an integer which, on input, indicates the uniqueness property being asserted by the caller: 1 if the indices are unique, and 0 otherwise. If equal to 0 on input but the indices are unique, then the value pointed to is changed to 1. |
Matrix is either 0-based or 1-based.
Column indices are legal.
References ERR_FALSE_INMATPROP, oski_Free, oski_HandleError, and oski_MallocNoError.
Referenced by oski_CheckCSR().
static int oski_CheckIndexBase | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | n, | |||
oski_index_t | base_index | |||
) | [static] |
Returns 1 <==> indices match the specified base.
All pointer arguments are non-NULL.
References ERR_FALSE_INMATPROP, and oski_HandleError.
Referenced by oski_CheckCSR().
static int oski_CheckIndNonDecreasing | ( | const oski_index_t * | ptr, | |
oski_index_t | m | |||
) | [static] |
Returns 1 <==> pointers are non-decreasing.
[in] | ptr | Row pointers. |
[in] | m | Number of rows. |
References ERR_FALSE_INMATPROP, and oski_HandleError.
Referenced by oski_CheckCSR().
static int oski_CheckIsLowerTriangular | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | b | |||
) | [static] |
Returns 0 <==> Pattern is lower triangular, and returns the offending logical row number (1-based) otherwise.
This implementation does not call the error handler if the pattern is not lower triangular.
Referenced by oski_CheckPattern().
static int oski_CheckIsUpperTriangular | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | b | |||
) | [static] |
Returns 0 <==> Pattern is upper triangular, and returns the offending logical row number (1-based) otherwise.
This implementation does not call the error handler if the pattern is not upper triangular.
Referenced by oski_CheckPattern().
static int oski_CheckPattern | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | n, | |||
oski_index_t | b, | |||
oski_inmatprop_t | pattern | |||
) | [static] |
Verify that the stored part of the CSR matrix matches the specified pattern.
[in] | ptr | Row pointers. |
[in] | ind | Column indices. |
[in] | m | Number of rows. |
[in] | n | Number of cols. |
[in] | b | Base index. |
[in] | pattern | Asserted pattern type. |
References ERR_FALSE_INMATPROP, MAT_HERM_FULL, MAT_HERM_LOWER, MAT_HERM_UPPER, MAT_SYMM_FULL, MAT_SYMM_LOWER, MAT_SYMM_UPPER, MAT_TRI_LOWER, MAT_TRI_UPPER, oski_CheckIsLowerTriangular(), oski_CheckIsUpperTriangular(), and oski_HandleError.
Referenced by oski_CheckCSR().
static int oski_CheckUnitDiagImplicit | ( | const oski_index_t * | ptr, | |
const oski_index_t * | ind, | |||
oski_index_t | m, | |||
oski_index_t | b, | |||
int | has_unit_diag_implicit | |||
) | [static] |
Verify whether or not matrix has an implicit unit diagonal.
[in] | ptr | Row pointers. |
[in] | ind | Column indices. |
[in] | m | Number of rows. |
[in] | b | Base index (0 or 1). |
[in,out] | has_unit_diag_implicit | An integer specifying whether the caller believes the pattern has an implicit unit diagonal (=1) or not (=0). |
References ERR_FALSE_INMATPROP, and oski_HandleError.
Referenced by oski_CheckCSR().