Motr  M0
matvec.h File Reference
#include "lib/types.h"
#include "parity_ops.h"
Include dependency graph for matvec.h:

Go to the source code of this file.

Data Structures

struct  m0_matvec
 
struct  m0_matrix
 

Macros

#define __MOTR_SNS_MAT_VEC_H__
 

Typedefs

typedef m0_parity_elem_t(* m0_matvec_matrix_binary_operator_t) (m0_parity_elem_t, m0_parity_elem_t)
 

Functions

M0_INTERNAL int m0_matvec_init (struct m0_matvec *v, uint32_t sz)
 
M0_INTERNAL void m0_matvec_fini (struct m0_matvec *v)
 
M0_INTERNAL void m0_matvec_print (const struct m0_matvec *vec)
 
m0_parity_elem_tm0_matvec_elem_get (const struct m0_matvec *v, uint32_t x)
 
M0_INTERNAL int m0_matrix_init (struct m0_matrix *m, uint32_t w, uint32_t h)
 
M0_INTERNAL void m0_matrix_fini (struct m0_matrix *m)
 
M0_INTERNAL void m0_matrix_print (const struct m0_matrix *mat)
 
m0_parity_elem_tm0_matrix_elem_get (const struct m0_matrix *m, uint32_t x, uint32_t y)
 
M0_INTERNAL void m0_matvec_row_operate (struct m0_matvec *v, uint32_t row, m0_parity_elem_t c, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_row_operate (struct m0_matrix *m, uint32_t row, m0_parity_elem_t c, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_col_operate (struct m0_matrix *m, uint32_t col, m0_parity_elem_t c, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_rows_operate (struct m0_matrix *m, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f0, m0_parity_elem_t c0, m0_matvec_matrix_binary_operator_t f1, m0_parity_elem_t c1, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_rows_operate2 (struct m0_matrix *m, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f0, m0_parity_elem_t c0, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_rows_operate1 (struct m0_matrix *m, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f1, m0_parity_elem_t c1, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matvec_rows_operate (struct m0_matvec *v, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f0, m0_parity_elem_t c0, m0_matvec_matrix_binary_operator_t f1, m0_parity_elem_t c1, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matvec_rows_operate1 (struct m0_matvec *v, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f1, m0_parity_elem_t c1, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matvec_rows_operate2 (struct m0_matvec *v, uint32_t row0, uint32_t row1, m0_matvec_matrix_binary_operator_t f0, m0_parity_elem_t c0, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_cols_operate (struct m0_matrix *m, uint32_t col0, uint32_t col1, m0_matvec_matrix_binary_operator_t f0, m0_parity_elem_t c0, m0_matvec_matrix_binary_operator_t f1, m0_parity_elem_t c1, m0_matvec_matrix_binary_operator_t f)
 
M0_INTERNAL void m0_matrix_swap_row (struct m0_matrix *m, uint32_t r0, uint32_t r1)
 
M0_INTERNAL void m0_matvec_swap_row (struct m0_matvec *v, uint32_t r0, uint32_t r1)
 
M0_INTERNAL void m0_matrix_vec_multiply (const struct m0_matrix *m, const struct m0_matvec *v, struct m0_matvec *r, m0_matvec_matrix_binary_operator_t mul, m0_matvec_matrix_binary_operator_t add)
 
M0_INTERNAL void m0_matrix_submatrix_get (const struct m0_matrix *mat, struct m0_matrix *submat, uint32_t x, uint32_t y)
 
M0_INTERNAL void m0_matrix_multiply (const struct m0_matrix *ma, const struct m0_matrix *mb, struct m0_matrix *mc)
 
M0_INTERNAL void m0_identity_matrix_fill (struct m0_matrix *identity_mat)
 
M0_INTERNAL bool m0_matrix_is_init (const struct m0_matrix *mat)
 
M0_INTERNAL bool m0_matrix_is_null (const struct m0_matrix *mat)
 
M0_INTERNAL void m0_matrix_row_copy (struct m0_matrix *des, const struct m0_matrix *src, uint32_t des_row, uint32_t src_row)
 
M0_INTERNAL bool m0_matrix_is_square (const struct m0_matrix *mat)
 

Macro Definition Documentation

◆ __MOTR_SNS_MAT_VEC_H__

#define __MOTR_SNS_MAT_VEC_H__

Definition at line 26 of file matvec.h.

Typedef Documentation

◆ m0_matvec_matrix_binary_operator_t

typedef m0_parity_elem_t(* m0_matvec_matrix_binary_operator_t) (m0_parity_elem_t, m0_parity_elem_t)

Defines binary operation over matrix or vector element

Definition at line 76 of file matvec.h.

Function Documentation

◆ m0_identity_matrix_fill()

M0_INTERNAL void m0_identity_matrix_fill ( struct m0_matrix identity_mat)

Populates the input square matrix as an identity matrix.

Precondition
M0_MATRIX_IS_SQUARE(identity_matrix)

Definition at line 371 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_col_operate()

M0_INTERNAL void m0_matrix_col_operate ( struct m0_matrix m,
uint32_t  col,
m0_parity_elem_t  c,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every col element of matrix 'm' in col 'col' with const 'c': m(i,col) = f(m(i,col), c);

Precondition
m0_matrix_init(m) has been called

Definition at line 234 of file matvec.c.

Here is the call graph for this function:

◆ m0_matrix_cols_operate()

M0_INTERNAL void m0_matrix_cols_operate ( struct m0_matrix m,
uint32_t  col0,
uint32_t  col1,
m0_matvec_matrix_binary_operator_t  f0,
m0_parity_elem_t  c0,
m0_matvec_matrix_binary_operator_t  f1,
m0_parity_elem_t  c1,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every col element of matrix 'm' in col 'col0' with col 'col1' and apply operation 'fi' to every col element of matrix 'm' in col 'coli' with const 'ci': m(i,col0) = f(f0(m(i,col0),c0), f1(m(i,col1),c1));

Precondition
m0_matrix_init(m) has been called

Definition at line 215 of file matvec.c.

Here is the call graph for this function:

◆ m0_matrix_elem_get()

m0_parity_elem_t* m0_matrix_elem_get ( const struct m0_matrix m,
uint32_t  x,
uint32_t  y 
)

Gets element of matrix 'm' in ('x','y') pos

Precondition
m0_matrix_init(v) has been called
x < m->m_width && y < m->m_height

Definition at line 86 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matrix_fini()

M0_INTERNAL void m0_matrix_fini ( struct m0_matrix m)

Definition at line 70 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matrix_init()

M0_INTERNAL int m0_matrix_init ( struct m0_matrix m,
uint32_t  w,
uint32_t  h 
)

Definition at line 49 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_is_init()

M0_INTERNAL bool m0_matrix_is_init ( const struct m0_matrix mat)

Verifies whether input matrix is initialized or not.

Parameters
[in]mat
Return values
'true'if mat->m_width > 0 && mat->m_height > 0.
'false'otherwise.

Definition at line 387 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matrix_is_null()

M0_INTERNAL bool m0_matrix_is_null ( const struct m0_matrix mat)

Definition at line 393 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_is_square()

M0_INTERNAL bool m0_matrix_is_square ( const struct m0_matrix mat)

Definition at line 413 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matrix_multiply()

M0_INTERNAL void m0_matrix_multiply ( const struct m0_matrix ma,
const struct m0_matrix mb,
struct m0_matrix mc 
)

Multiplies matrix ma with matrix mb and stores the result in matrix mc

Parameters
[in]ma
[in]mb
[out]mc
Precondition
mc->m_height == ma->m_height
mc->m_width == mb->m_width
mc->m_matrix[i][j] == 0 0 <= i < mc->m_height 0 <= j < mc->m_width

Definition at line 342 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_print()

M0_INTERNAL void m0_matrix_print ( const struct m0_matrix mat)

Definition at line 93 of file matvec.c.

Here is the call graph for this function:

◆ m0_matrix_row_copy()

M0_INTERNAL void m0_matrix_row_copy ( struct m0_matrix des,
const struct m0_matrix src,
uint32_t  des_row,
uint32_t  src_row 
)

Copies src_row from src to des_row in des.

Parameters
[out]desdestination matrix
[in]srcsource matrix
[in]des_rowdestination row index
[in]src_rowsource row index
Precondition
dest->m_width == src->m_width

Definition at line 400 of file matvec.c.

Here is the call graph for this function:

◆ m0_matrix_row_operate()

M0_INTERNAL void m0_matrix_row_operate ( struct m0_matrix m,
uint32_t  row,
m0_parity_elem_t  c,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of matrix 'm' in row 'row' with const 'c': m(row,i) = f(m(row,i), c);

Precondition
m0_matvec_init(v) has been called

Definition at line 142 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_rows_operate()

M0_INTERNAL void m0_matrix_rows_operate ( struct m0_matrix m,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f0,
m0_parity_elem_t  c0,
m0_matvec_matrix_binary_operator_t  f1,
m0_parity_elem_t  c1,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of matrix 'm' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of matrix 'm' in row 'rowi' with const 'ci': m(row0,i) = f(f0(m(row0,i),c0), f1(m(row1,i),c1));

Precondition
m0_matrix_init(m) has been called

Definition at line 165 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_rows_operate1()

M0_INTERNAL void m0_matrix_rows_operate1 ( struct m0_matrix m,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f1,
m0_parity_elem_t  c1,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of matrix 'm' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of matrix 'm' in row 'rowi' with const 'ci': m(row0,i) = f(m(row0,i), f1(m(row1,i),c1));

Precondition
m0_matrix_init(m) has been called

Definition at line 199 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_rows_operate2()

M0_INTERNAL void m0_matrix_rows_operate2 ( struct m0_matrix m,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f0,
m0_parity_elem_t  c0,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of matrix 'm' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of matrix 'm' in row 'rowi' with const 'ci': m(row0,i) = f(f0(m(row0,i),c0), m(row1,i));

Precondition
m0_matrix_init(m)

Definition at line 183 of file matvec.c.

Here is the call graph for this function:

◆ m0_matrix_submatrix_get()

M0_INTERNAL void m0_matrix_submatrix_get ( const struct m0_matrix mat,
struct m0_matrix submat,
uint32_t  x,
uint32_t  y 
)

Returns submatrix of matrix 'mat' into 'submat', where 'x', 'y' - offsets Uses 'submat' dimensions

Precondition
m0_matrix_init(mat) has been called
m0_matrix_init(submat) has been called

Definition at line 324 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matrix_swap_row()

M0_INTERNAL void m0_matrix_swap_row ( struct m0_matrix m,
uint32_t  r0,
uint32_t  r1 
)

Swaps row 'r0' and row 'r1' each with other

Precondition
m0_matrix_init(m) has been called

Definition at line 120 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matrix_vec_multiply()

M0_INTERNAL void m0_matrix_vec_multiply ( const struct m0_matrix m,
const struct m0_matvec v,
struct m0_matvec r,
m0_matvec_matrix_binary_operator_t  mul,
m0_matvec_matrix_binary_operator_t  add 
)

Multiplies matrix 'm' on vector 'v' Returns vector 'r'

Parameters
mul- multiplicaton function
add- addition function
Precondition
m0_matvec_init(v) has been called
m0_matrix_init(m) has been called
m0_vec_init(r) has been called

Definition at line 298 of file matvec.c.

Here is the call graph for this function:

◆ m0_matvec_elem_get()

m0_parity_elem_t* m0_matvec_elem_get ( const struct m0_matvec v,
uint32_t  x 
)

Gets element of vector 'v' in 'x' row

Precondition
m0_matvec_init(v) has been called
x < v->mv_size

Definition at line 80 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matvec_fini()

M0_INTERNAL void m0_matvec_fini ( struct m0_matvec v)

Definition at line 43 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matvec_init()

M0_INTERNAL int m0_matvec_init ( struct m0_matvec v,
uint32_t  sz 
)

Definition at line 36 of file matvec.c.

Here is the caller graph for this function:

◆ m0_matvec_print()

M0_INTERNAL void m0_matvec_print ( const struct m0_matvec vec)

Definition at line 109 of file matvec.c.

Here is the call graph for this function:

◆ m0_matvec_row_operate()

M0_INTERNAL void m0_matvec_row_operate ( struct m0_matvec v,
uint32_t  row,
m0_parity_elem_t  c,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to element of vector 'v' in row 'row' with const 'c': v[row] = f(v[row], c);

Precondition
m0_matvec_init(v) has been called

Definition at line 155 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matvec_rows_operate()

M0_INTERNAL void m0_matvec_rows_operate ( struct m0_matvec v,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f0,
m0_parity_elem_t  c0,
m0_matvec_matrix_binary_operator_t  f1,
m0_parity_elem_t  c1,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of vector 'v' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of vector 'v' in row 'rowi' with const 'ci': m(row0,i) = f(f0(m(row0,i),c0), f1(m(row1,i),c1));

Precondition
m0_matvec_init(v) has been called

Definition at line 247 of file matvec.c.

Here is the call graph for this function:

◆ m0_matvec_rows_operate1()

M0_INTERNAL void m0_matvec_rows_operate1 ( struct m0_matvec v,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f1,
m0_parity_elem_t  c1,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of vector 'v' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of vector 'v' in row 'rowi' with const 'ci': m(row0,i) = f(m(row0,i), f1(m(row1,i),c1));

Precondition
m0_matvec_init(v) has been called

Definition at line 265 of file matvec.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_matvec_rows_operate2()

M0_INTERNAL void m0_matvec_rows_operate2 ( struct m0_matvec v,
uint32_t  row0,
uint32_t  row1,
m0_matvec_matrix_binary_operator_t  f0,
m0_parity_elem_t  c0,
m0_matvec_matrix_binary_operator_t  f 
)

Apply operation 'f' to every row element of vector 'v' in row 'row0' with row 'row1' and apply operation 'fi' to every row element of vector 'v' in row 'rowi' with const 'ci': m(row0,i) = f(f0(m(row0,i),c0), m(row1,i));

Precondition
m0_matvec_init(v) has been called

Definition at line 281 of file matvec.c.

Here is the call graph for this function:

◆ m0_matvec_swap_row()

M0_INTERNAL void m0_matvec_swap_row ( struct m0_matvec v,
uint32_t  r0,
uint32_t  r1 
)

Swaps row 'r0' and row 'r1' each with other

Precondition
m0_matvec_init(v) has been called

Definition at line 131 of file matvec.c.

Here is the caller graph for this function: