BeBOP Optimized Sparse Kernel Interface Library  1.0.1h
Defines | Functions
getset.c File Reference

Get/set value routines. More...

#include <oski/common.h>
#include <oski/config.h>
#include <oski/mangle.h>
#include <oski/matrix.h>
#include <oski/getset.h>

Defines

#define MIN(i, j)   ((i) < (j) ? (i) : (j))
 Returns the smallest of two values.
#define MAX(i, j)   ((i) > (j) ? (i) : (j))
 Returns the largest of two values.

Functions

static int GetMatEntry (const oski_matspecific_t *mat, const oski_matcommon_t *props, oski_index_t row, oski_index_t col, oski_value_t *p_aij)
 Calls matrix type-specific implementation of oski_GetMatEntry().
static int SetMatEntry (const oski_matspecific_t *mat, const oski_matcommon_t *props, oski_index_t row, oski_index_t col, oski_value_t new_val)
 Calls matrix type-specific implementation of oski_SetMatEntry().
oski_value_t oski_GetMatEntry (const oski_matrix_t A_tunable, oski_index_t row, oski_index_t col)
 Returns the value of a matrix element.
int oski_SetMatEntry (const oski_matrix_t A_tunable, oski_index_t row, oski_index_t col, oski_value_t new_val)
 Changes the value of the specified matrix element.
static int FindIndexOutOfRange (const oski_index_t *x, oski_index_t n, oski_index_t min, oski_index_t max)
 Returns the index of any element not in the specified closed interval, or -1 if all elements are in the interval.
static int GetMaxIndex (const oski_index_t *x, oski_index_t n)
 Returns the largest value in the specified array.
static int CheckCliqueArgs (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, oski_vecview_t vals, const char *caller)
 Checks the input arguments to oski_GetMatClique() and oski_SetMatClique(), returning 0 if the arguments are valid or an error code otherwise.
static int GetClique (const oski_matspecific_t *mat, const oski_matcommon_t *props, const oski_index_t *rows, oski_index_t R, const oski_index_t *cols, oski_index_t C, const oski_vecview_t V)
 Given a type-specific representation, try to find a native oski_GetMatReprClique() implementation and call it.
static int GetCliqueDefault (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, oski_vecview_t V)
 Returns a clique using a default naive algorithm that just calls oski_GetMatEntry() repeatedly.
int oski_GetMatClique (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, oski_vecview_t vals)
 This implementation tries to find a matrix type-specific implementation (oski_GetMatReprClique()) and, failing that, calls a default implementation based on repeatedly calling oski_GetMatEntry().
static int SetClique (const oski_matspecific_t *mat, const oski_matcommon_t *props, const oski_index_t *rows, oski_index_t R, const oski_index_t *cols, oski_index_t C, const oski_vecview_t V)
 Given a type-specific representation, try to find a native oski_SetMatReprClique() implementation and call it.
static int SetCliqueDefault (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, oski_vecview_t V)
 Returns a clique using a default naive algorithm that just calls oski_SetMatEntry() repeatedly.
int oski_SetMatClique (const oski_matrix_t A_tunable, const oski_index_t *rows, oski_index_t num_rows, const oski_index_t *cols, oski_index_t num_cols, const oski_vecview_t vals)
 This implementation tries to find a matrix type-specific implementation (oski_SetMatReprClique()) and, failing that, calls a default implementation based on repeatedly calling oski_SetMatEntry().
static int CheckDiagValuesArgs (const oski_matrix_t A_tunable, oski_index_t d, oski_vecview_t vals, const char *caller)
 Checks the input arguments to oski_GetMatDiagValues() and oski_SetMatDiagValues(), returning 0 if the arguments are valid or an error code otherwise.
static int GetDiagValues (const oski_matspecific_t *mat, const oski_matcommon_t *props, oski_index_t d, oski_vecview_t V)
 Given a type-specific representation, try to find a native oski_GetMatReprDiagValues() implementation and call it.
static int GetDiagValuesDefault (const oski_matrix_t A_tunable, oski_index_t d, oski_vecview_t V)
 Returns a clique using a default naive algorithm that just calls oski_GetMatEntry() repeatedly.
int oski_GetMatDiagValues (const oski_matrix_t A_tunable, oski_index_t diag_num, oski_vecview_t diag_vals)
 This implementation tries to find a matrix type-specific implementation (oski_GetMatReprDiagValues()) and, failing that, calls a default implementation based on repeatedly calling oski_GetMatEntry().
static int SetDiagValues (const oski_matspecific_t *mat, const oski_matcommon_t *props, oski_index_t d, const oski_vecview_t V)
 Given a type-specific representation, try to find a native oski_SetMatReprDiagValues() implementation and call it.
static int SetDiagValuesDefault (const oski_matrix_t A_tunable, oski_index_t d, const oski_vecview_t V)
 Sets values along a given diagonal using a default naive algorithm that just calls oski_SetMatEntry() repeatedly.
int oski_SetMatDiagValues (const oski_matrix_t A_tunable, oski_index_t diag_num, const oski_vecview_t diag_vals)
 This implementation tries to find a matrix type-specific implementation (oski_SetMatReprDiagValues()) and, failing that, calls a default implementation based on repeatedly calling oski_SetMatEntry().

Detailed Description

Get/set value routines.


Define Documentation

#define MAX (   i,
 
)    ((i) > (j) ? (i) : (j))

Returns the largest of two values.

Referenced by CheckDiagValuesArgs().

#define MIN (   i,
 
)    ((i) < (j) ? (i) : (j))

Returns the smallest of two values.

Referenced by CheckDiagValuesArgs(), GetDiagValuesDefault(), and SetDiagValuesDefault().


Function Documentation

static int CheckCliqueArgs ( const oski_matrix_t  A_tunable,
const oski_index_t *  rows,
oski_index_t  num_rows,
const oski_index_t *  cols,
oski_index_t  num_cols,
oski_vecview_t  vals,
const char *  caller 
) [static]

Checks the input arguments to oski_GetMatClique() and oski_SetMatClique(), returning 0 if the arguments are valid or an error code otherwise.

This routine calls the error handler on error, using the method name, 'caller'.

References ERR_BAD_ARG, FindIndexOutOfRange(), GetMaxIndex(), INVALID_MAT, INVALID_VEC, oski_matcommon_t::num_cols, oski_vecstruct_t::num_cols, oski_matcommon_t::num_rows, oski_vecstruct_t::num_rows, OSKI_ERR_BAD_MAT_MS, OSKI_ERR_BAD_ROW_MS, OSKI_ERR_BAD_VEC_MS, OSKI_ERR_CLIQUE_VALMAT_SMALL_MS, OSKI_ERR_NULL_ARG_MS, OSKI_ERR_SMALL_ARG_MS, and oski_matstruct_t::props.

Referenced by oski_GetMatClique(), and oski_SetMatClique().

static int CheckDiagValuesArgs ( const oski_matrix_t  A_tunable,
oski_index_t  d,
oski_vecview_t  vals,
const char *  caller 
) [static]

Checks the input arguments to oski_GetMatDiagValues() and oski_SetMatDiagValues(), returning 0 if the arguments are valid or an error code otherwise.

This routine calls the error handler on error, using the method name, 'caller'.

References ERR_BAD_ARG, INVALID_MAT, IS_VAL_IN_RANGE, MAX, MIN, oski_matcommon_t::num_cols, oski_vecstruct_t::num_cols, oski_matcommon_t::num_rows, oski_vecstruct_t::num_rows, OSKI_ERR_BAD_DIAG_MS, OSKI_ERR_BAD_MAT_MS, OSKI_ERR_DIAG_VALMAT_SMALL_MS, and oski_matstruct_t::props.

Referenced by oski_GetMatDiagValues(), and oski_SetMatDiagValues().

static int FindIndexOutOfRange ( const oski_index_t *  x,
oski_index_t  n,
oski_index_t  min,
oski_index_t  max 
) [static]

Returns the index of any element not in the specified closed interval, or -1 if all elements are in the interval.

The index returned is 0-based.

Referenced by CheckCliqueArgs().

static int GetClique ( const oski_matspecific_t mat,
const oski_matcommon_t props,
const oski_index_t *  rows,
oski_index_t  R,
const oski_index_t *  cols,
oski_index_t  C,
const oski_vecview_t  V 
) [static]

Given a type-specific representation, try to find a native oski_GetMatReprClique() implementation and call it.

If none exists, returns ERR_NOT_IMPLEMENTED. Otherwise, calls the native function and returns its error code.

References ERR_NOT_IMPLEMENTED, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_GetMatClique().

static int GetCliqueDefault ( const oski_matrix_t  A_tunable,
const oski_index_t *  rows,
oski_index_t  num_rows,
const oski_index_t *  cols,
oski_index_t  num_cols,
oski_vecview_t  V 
) [static]

Returns a clique using a default naive algorithm that just calls oski_GetMatEntry() repeatedly.

Precondition:
Assumes all arguments are valid. See CheckCliqueArgs().

References oski_vecstruct_t::colinc, oski_vecstruct_t::rowinc, oski_vecstruct_t::val, and VAL_ASSIGN.

Referenced by oski_GetMatClique().

static int GetDiagValues ( const oski_matspecific_t mat,
const oski_matcommon_t props,
oski_index_t  d,
oski_vecview_t  V 
) [static]

Given a type-specific representation, try to find a native oski_GetMatReprDiagValues() implementation and call it.

If none exists, returns ERR_NOT_IMPLEMENTED. Otherwise, calls the native function and returns its error code.

References ERR_NOT_IMPLEMENTED, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_GetMatDiagValues().

static int GetDiagValuesDefault ( const oski_matrix_t  A_tunable,
oski_index_t  d,
oski_vecview_t  V 
) [static]

Returns a clique using a default naive algorithm that just calls oski_GetMatEntry() repeatedly.

Precondition:
Assumes all arguments are valid. See CheckDiagValuesArgs().

References MIN, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, oski_matstruct_t::props, oski_vecstruct_t::rowinc, oski_vecstruct_t::val, and VAL_ASSIGN.

Referenced by oski_GetMatDiagValues().

static int GetMatEntry ( const oski_matspecific_t mat,
const oski_matcommon_t props,
oski_index_t  row,
oski_index_t  col,
oski_value_t *  p_aij 
) [static]

Calls matrix type-specific implementation of oski_GetMatEntry().

Parameters:
[in]matType-specific data structure.
[in]propsType-independent properties.
[in]rowRow of entry to retrieve (1-based).
[in]colColumn of entry to retrieve (1-based).
[in,out]p_aijPointer to buffer into which the (row, col) entry is returned.
Returns:
On success, sets *p_aij to $a_{\mathrm{row}, \mathrm{col}}$ and returns 0. Returns an error code otherwise. This routine calls the error handler unless the error that there is no matrix type-specific implementation. (In this case, the caller has an opportunity to try calling the type-specific implementation of another representation.)

References ERR_NOT_IMPLEMENTED, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_GetMatEntry().

static int GetMaxIndex ( const oski_index_t *  x,
oski_index_t  n 
) [static]

Returns the largest value in the specified array.

Precondition:
n >= 1 && x != NULL

Referenced by CheckCliqueArgs().

static int SetClique ( const oski_matspecific_t mat,
const oski_matcommon_t props,
const oski_index_t *  rows,
oski_index_t  R,
const oski_index_t *  cols,
oski_index_t  C,
const oski_vecview_t  V 
) [static]

Given a type-specific representation, try to find a native oski_SetMatReprClique() implementation and call it.

If none exists, returns ERR_NOT_IMPLEMENTED. Otherwise, calls the native function and returns its error code.

References ERR_NOT_IMPLEMENTED, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_SetMatClique().

static int SetCliqueDefault ( const oski_matrix_t  A_tunable,
const oski_index_t *  rows,
oski_index_t  num_rows,
const oski_index_t *  cols,
oski_index_t  num_cols,
oski_vecview_t  V 
) [static]

Returns a clique using a default naive algorithm that just calls oski_SetMatEntry() repeatedly.

Precondition:
Assumes all arguments are valid. See CheckCliqueArgs().

References oski_vecstruct_t::colinc, oski_vecstruct_t::rowinc, oski_vecstruct_t::val, and VAL_ASSIGN.

Referenced by oski_SetMatClique().

static int SetDiagValues ( const oski_matspecific_t mat,
const oski_matcommon_t props,
oski_index_t  d,
const oski_vecview_t  V 
) [static]

Given a type-specific representation, try to find a native oski_SetMatReprDiagValues() implementation and call it.

If none exists, returns ERR_NOT_IMPLEMENTED. Otherwise, calls the native function and returns its error code.

References ERR_NOT_IMPLEMENTED, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_SetMatDiagValues().

static int SetDiagValuesDefault ( const oski_matrix_t  A_tunable,
oski_index_t  d,
const oski_vecview_t  V 
) [static]

Sets values along a given diagonal using a default naive algorithm that just calls oski_SetMatEntry() repeatedly.

Precondition:
Assumes all arguments are valid. See CheckDiagValuesArgs().

References MIN, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, oski_matstruct_t::props, oski_vecstruct_t::rowinc, oski_vecstruct_t::val, and VAL_ASSIGN.

Referenced by oski_SetMatDiagValues().

static int SetMatEntry ( const oski_matspecific_t mat,
const oski_matcommon_t props,
oski_index_t  row,
oski_index_t  col,
oski_value_t  new_val 
) [static]

Calls matrix type-specific implementation of oski_SetMatEntry().

Parameters:
[in]matType-specific data structure.
[in]propsType-independent properties.
[in]rowRow of entry to set (1-based).
[in]colColumn of entry to set (1-based).
[in]new_valNew value for the specified entry.
Returns:
On success, sets $a_{\mathrm{row}, \mathrm{col}}$ to new_val and returns 0. This routine returns an error code otherwise, and calls the error handler unless 'mat' has an invalid type id.

References ERR_BAD_ID, ERR_NOT_IMPLEMENTED, INVALID_ID, OSKI_ERR_MATTYPEID_MEMBER, OSKI_MATTYPEID_METHOD, oski_matspecific_t::repr, and oski_matspecific_t::type_id.

Referenced by oski_SetMatEntry().