-
Notifications
You must be signed in to change notification settings - Fork 0
/
mv_ops.h
45 lines (36 loc) · 1.11 KB
/
mv_ops.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* mv_ops.h - Matrix/Vector Operations
*
* CSC 564 - CG Assignment Series
*
* Author: Dean Pucsek
* Date: 10 February 2012
*
*/
#ifndef __MV_OPS_H__
#define __MV_OPS_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct __mv_sparse {
int size;
int nnz;
double *values;
int *col_indices;
int *row_ptr;
};
/* Creating & Destroying Sparse Objects */
struct __mv_sparse *new_mv_struct();
struct __mv_sparse *new_mv_struct_with_size(int);
void free_mv_struct(struct __mv_sparse *);
struct __mv_sparse *mv_deep_copy(struct __mv_sparse *);
/* Printing */
void print_sparse(struct __mv_sparse *);
/* Accessing Matrix Rows */
int mat_get_row(struct __mv_sparse *, int, double *);
/* Arithmetic Operations */
double dot_product(struct __mv_sparse *, struct __mv_sparse *);
int sv_mult(double, struct __mv_sparse *, struct __mv_sparse **);
int mv_mult(struct __mv_sparse *, struct __mv_sparse *, struct __mv_sparse **);
int vec_add(struct __mv_sparse *, struct __mv_sparse *, struct __mv_sparse **);
int vec_sub(struct __mv_sparse *, struct __mv_sparse *, struct __mv_sparse **);
#endif /* __MV_OPS_H__ */