module.c File Reference


Detailed Description

Compressed sparse row (CSR) module.

#include <math.h>
#include <string.h>
#include <oski/config.h>
#include <oski/common.h>
#include <oski/matrix.h>
#include <oski/CSR/module.h>

Functions

const char * oski_GetShortDesc (void)
 Method: Returns a short string description of the module.
const char * oski_GetLongDesc (void)
 Method: Returns a "long" string description of the module.
void oski_InitModule (void)
 Method: Initialize the module.
void oski_CloseModule (void)
 Method: Shutdown the module.
static int CopyPointers (oski_matCSR_t *A, oski_copymode_t mode, oski_index_t *ptr, oski_index_t *ind, oski_value_t *val, oski_index_t m, oski_index_t index_base)
 Copy raw CSR representation to a concrete CSR matrix type representation.
static oski_index_t CountDiagElems (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t b)
 Returns the number of explicitly stored diagonal elements.
static void SetCommonProps (oski_matcommon_t *out_props, const oski_index_t *ptr, const oski_index_t *ind, oski_index_t m, oski_index_t n, const oski_inmatpropset_t *props)
 Translate asserted properties of the input matrix into common properties of the output matrix.
static void SetMatTypeProps (oski_matCSR_t *A_csr, const oski_matcommon_t *out_props, const oski_inmatpropset_t *props)
 Set CSR properties based on common properties and asserted input matrix properties.
oski_matCSR_toski_WrapCSR (oski_matcommon_t *out_props, oski_index_t *Aptr, oski_index_t *Aind, oski_value_t *Aval, oski_index_t num_rows, oski_index_t num_cols, oski_inmatpropset_t *props, oski_copymode_t mode)
 Create a new CSR-specific wrapper around a raw CSR array representation.
void oski_DestroyMatRepr (void *mat)
 Method: Destroy matrix type-specific representation.
void * oski_CreateMatReprFromCSR (const oski_matCSR_t *mat, const oski_matcommon_t *props,...)
 Method: Instantiate from an existing CSR representation.
oski_matCSR_toski_ConvertMatReprToCSR (const void *mat, const oski_matcommon_t *props)
 Method: Convert to CSR format.
void * oski_CopyMatRepr (const void *mat, const oski_matcommon_t *props)
 Method: Duplicate a matrix representation.
double oski_StreamMatRepr (const void *mat, const oski_matcommon_t *props)
 Stream through a matrix.
void oski_ChangeIndexBase (oski_matCSR_t *A, const oski_matcommon_t *props, const oski_index_t new_base)
 Change the index base of a matrix.
double oski_CalcMatRepr1Norm (const void *mat, const oski_matcommon_t *props)
 Method: Compute the 1-norm.
oski_index_t oski_CountZeroRowsCSR (const oski_matCSR_t *A, const oski_matcommon_t *props)
 Returns the number of rows in a given CSR matrix that contain no structural non-zeros.


Function Documentation

static int CopyPointers oski_matCSR_t A,
oski_copymode_t  mode,
oski_index_t *  ptr,
oski_index_t *  ind,
oski_value_t *  val,
oski_index_t  m,
oski_index_t  index_base
[static]
 

Copy raw CSR representation to a concrete CSR matrix type representation.

Parameters:
[out] A Concrete CSR object.
[in] mode Copy mode.
[in] m Number of rows in the raw representation.
[in] ptr Row pointers of the raw representation.
[in] ind Column indices of the raw representation.
[in] val Non-zero values of the raw representation.
[in] index_base Base index for interpreting the values in ptr and ind.
Returns:
1 if successful, 0 otherwise.
Precondition:
All pointers are non-NULL.

The raw representation is valid.

m is valid (non-negative).

double oski_CalcMatRepr1Norm const void *  mat,
const oski_matcommon_t props
 

Method: Compute the 1-norm.

Todo:
Fix the symmetric case; this is only an estimate.

double oski_StreamMatRepr const void *  mat,
const oski_matcommon_t props
 

Stream through a matrix.

This routine streams through the matrix data structure, performs some dummy computations, and returns the results. We use this routine to help estimate the cost of a matrix-vector multiply operation on a given matrix without actually having to perform matrix-vector multiply.

oski_matCSR_t* oski_WrapCSR oski_matcommon_t out_props,
oski_index_t *  Aptr,
oski_index_t *  Aind,
oski_value_t *  Aval,
oski_index_t  num_rows,
oski_index_t  num_cols,
oski_inmatpropset_t props,
oski_copymode_t  mode
 

Create a new CSR-specific wrapper around a raw CSR array representation.

If any of the asserted properties can be strengthened, then the parameter props (below) is changed accordingly. See oski_CheckCSR() for details.

Parameters:
[out] out_props Matrix type-independent properties, derived from the input properties props.
[in] Aptr Row pointers.
[in] Aind Column indices.
[in] Aval Non-zero values.
[in,out] props Semantic properties of the matrix represented by
[in] num_rows Number of rows.
[in] num_cols Number of columns. Aptr, Aind, and Aval.
[in] mode Specify the copy mode for the returned representation.
Precondition:
All pointer arguments are non-NULL

num_rows, num_cols are non-negative

mode is a legal value.

See also:
oski_wrapCSR_funcpt
Returns:
A matrix type-specific representation of the input matrix, or NULL on error.
Todo:
The output properties data structure actually defines a more general property about the diagonal, namely, that it is all ones. However, the available input matrix properties only allow the user to specify whether or not there is an implicit unit diagonal. Thus, it is possible that the user could create an input matrix with an explicit unit diagonal, but this condition is not checked when wrapping the data structure. It might be desirable to do this to make optimized triangular solve for the unit diagonal case more efficient.
Todo:
Similarly, the oski_matCSR_t data structure has "is_upper" and "is_lower" flags, which could be set even if the user asserts that the matrix has a "general" pattern.

Basic steps:

  1. Check asserted properties.
  2. Create a CSR handle.
  3. Copy buffers (deep or shallow copy, depending on mode)
  4. Set common properties.
  5. Set matrix-specific properties.
  6. Return.

static void SetCommonProps oski_matcommon_t out_props,
const oski_index_t *  ptr,
const oski_index_t *  ind,
oski_index_t  m,
oski_index_t  n,
const oski_inmatpropset_t props
[static]
 

Translate asserted properties of the input matrix into common properties of the output matrix.

Parameters:
[out] out_props Output matrix common properties.
[in] ptr Row pointers.
[in] ind Column indices.
[in] m Number of logical rows.
[in] n Number of logical columns.
[in] props Asserted input matrix properties.
Precondition:
All input matrix properties are valid and pointers are non-NULL.
Postcondition:
Sets all fields of out_props.

static void SetMatTypeProps oski_matCSR_t A_csr,
const oski_matcommon_t out_props,
const oski_inmatpropset_t props
[static]
 

Set CSR properties based on common properties and asserted input matrix properties.

Parameters:
[in,out] A_csr A CSR representation whose properties have not yet been initialized.
[in] out_props Common properties of the final output matrix which A_csr will represent.
[in] props Asserted properties of the final output matrix which A_csr will represent.
This implementation does not set A_csr->is_shared, which is instead set in CopyPointers().

See also:
CopyPointers()


Generated on Wed Sep 19 16:41:22 2007 for BeBOP Optimized Sparse Kernel Interface Library by  doxygen 1.4.6