BeBOP Optimized Sparse Kernel Interface Library  1.0.1h
Functions
transpose.c File Reference

Implements a routine to transpose a CSR matrix. More...

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

Functions

static void cumulative_sum (const oski_index_t *x, oski_index_t n, oski_index_t *y)
 Given an array $x$ of $n$ values, this routine computes the cumulative sum $y_i = \sum_{k=0}^{i-1} x_k$, where $0 \leq i \leq n$.
static int TransposeFullCSR (const oski_index_t *ptr, const oski_index_t *ind, const oski_value_t *val, oski_index_t m, oski_index_t n, oski_index_t base, oski_index_t **p_Tptr, oski_index_t **p_Tind, oski_value_t **p_Tval)
 Transpose a full-storage $m\times n$ matrix $A$ stored in CSR matrix (or equivalently, convert from CSR to CSC).
static void ConjOffDiagElems (const oski_index_t *ptr, const oski_index_t *ind, oski_value_t *val, oski_index_t m, oski_index_t b)
 Conjugate all off-diagonal elements of a CSR representation.
oski_matCSR_toski_TransposeCSR (const oski_matCSR_t *A, const oski_matcommon_t *props)
 Given a matrix $A$ in CSR format, returns a copy of its explicit transpose $A^T$ in CSR format.

Detailed Description

Implements a routine to transpose a CSR matrix.


Function Documentation

static void ConjOffDiagElems ( const oski_index_t *  ptr,
const oski_index_t *  ind,
oski_value_t *  val,
oski_index_t  m,
oski_index_t  b 
) [static]

Conjugate all off-diagonal elements of a CSR representation.

References VAL_CONJ.

Referenced by oski_TransposeCSR().

static void cumulative_sum ( const oski_index_t *  x,
oski_index_t  n,
oski_index_t *  y 
) [static]

Given an array $x$ of $n$ values, this routine computes the cumulative sum $y_i = \sum_{k=0}^{i-1} x_k$, where $0 \leq i \leq n$.

Parameters:
[in]xArray of values to sum.
[in]nLength of $x$.
[in,out]yAn array of size $n+1$ used to store the cumulative sum.
Note:
This routine was "outlined" from its use in this module (TransposeFullCSR) to avoid an unexplained bug that occurred when using the Intel C compiler on IA-64.

Referenced by TransposeFullCSR().

oski_matCSR_t* oski_TransposeCSR ( const oski_matCSR_t A,
const oski_matcommon_t props 
)

Given a matrix $A$ in CSR format, returns a copy of its explicit transpose $A^T$ in CSR format.

Parameters:
[in]AMatrix $A$ to transpose.
[in]propsCommon properties of $A$.
Returns:
A pointer to a new CSR matrix storing $A^T$, or NULL on memory error.

This implementation maintains symmetric/Hermitian properties if they apply to $A$.

References oski_matCSR_t::base_index, ConjOffDiagElems(), ERR_OUT_OF_MEMORY, oski_matCSR_t::ind, oski_matcommon_t::is_herm, oski_matCSR_t::is_shared, oski_matcommon_t::is_symm, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, oski_CopyMem, OSKI_ERR, oski_Free, oski_Malloc, oski_matcommon_t::pattern, oski_matCSR_t::ptr, TransposeFullCSR(), and oski_matCSR_t::val.

static int TransposeFullCSR ( const oski_index_t *  ptr,
const oski_index_t *  ind,
const oski_value_t *  val,
oski_index_t  m,
oski_index_t  n,
oski_index_t  base,
oski_index_t **  p_Tptr,
oski_index_t **  p_Tind,
oski_value_t **  p_Tval 
) [static]

Transpose a full-storage $m\times n$ matrix $A$ stored in CSR matrix (or equivalently, convert from CSR to CSC).

Parameters:
[in]ptrRow pointers.
[in]indColumn indices.
[in]valNon-zero values, or NULL if the caller only wishes to transpose the pattern.
[in]mNumber of rows.
[in]nNumber of columns.
[in]baseIndex base used for ptr, ind.
[out]p_Tptr*p_Tptr stores the $n+1$ row pointers of $A^T$.
[out]p_Tind*p_Tind stores the column indices of $A^T$.
[out]p_Tval*p_Tval stores the non-zero values of $A^T$.
Returns:
0 on success, an error code otherwise. This routine does not call the error handler. If an error occurs, the output variables *p_Tptr, *p_Tind, and *p_Tval remain unchanged.

References cumulative_sum(), ERR_OUT_OF_MEMORY, ERR_WRONG_ANS, MACRO_TO_STRING, oski_Free, oski_FreeAll(), oski_HandleError, oski_Malloc, oski_MultiMalloc(), and VAL_ASSIGN.

Referenced by oski_TransposeCSR().