Program listing for file numerics/src/tools/NumericsSparseMatrix.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
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef NumericsSparseMatrix_H
#define NumericsSparseMatrix_H



#include <stdio.h>
#include "CSparseMatrix.h"
#include "NumericsFwd.h"
#include "SiconosConfig.h"


typedef struct linalg_data_t
{
  int id;
  void  (*free_fn)(struct linalg_data_t*);
} linalg_data_t;

typedef enum { SN_LINALG_UNKNOWN, SN_LINALG_MKL } linalg_data_id;

#if defined(__cplusplus) && !defined(BUILD_AS_CPP)
extern "C"
{
#endif



  typedef enum { NSM_CS_LUSOL, NSM_MUMPS, NSM_UMFPACK, NSM_MKL_PARDISO, NSM_SUPERLU, NSM_SUPERLU_MT, NSM_CS_CHOLSOL } NSM_linear_solver;

  typedef void (*freeNSLSP)(void* p);


  typedef enum { NSM_CS_CSC = -1, NSM_CS_CSR = -2 } NumericsSparseTypesNZ;


  struct NSM_linear_solver_params
  {
    NSM_linear_solver solver;

    void* linear_solver_data;
    freeNSLSP solver_free_hook;

    int* iWork;
    int iWorkSize;
    double* dWork;
    int dWorkSize;

    linalg_data_t* linalg_data;
  };


  typedef enum { NSM_UNKNOWN, NSM_TRIPLET, NSM_CSC, NSM_CSR, NSM_HALF_TRIPLET } NumericsSparseOrigin;



  struct NumericsSparseMatrix
  {
    CSparseMatrix* triplet;
    CSparseMatrix* half_triplet;
    CSparseMatrix* csc;
    CSparseMatrix* trans_csc;
    CSparseMatrix* csr;
    CS_INT*           diag_indx;
    unsigned       origin;
    NSM_linear_solver_params* linearSolverParams;


  };



  void NSM_null(NumericsSparseMatrix* A);


  NumericsSparseMatrix* NSM_new(void);

  NumericsSparseMatrix * NSM_triplet_eye(unsigned int size);


  NumericsSparseMatrix* NSM_clear(NumericsSparseMatrix* A);





  void NSM_clear_p(void *p);


  double* NSM_data(NumericsSparseMatrix* A);



  static inline void* NSM_linear_solver_data(NSM_linear_solver_params* p)
  {
    return p->linear_solver_data;
  }

  static inline double* NSM_workspace(NSM_linear_solver_params* p)

  {
    return p->dWork;
  }


  size_t NSM_nnz(const CSparseMatrix* const A);


  CS_INT* NSM_diag_indices(NumericsMatrix* M);



  void NSM_extract_block(NumericsMatrix* M, double* blockM, size_t pos_row, size_t pos_col, size_t block_row_size, size_t block_col_size);


  NSM_linear_solver_params* NSM_linearSolverParams_free(NSM_linear_solver_params* p);


  NSM_linear_solver_params* NSM_linearSolverParams_new(void);



  NSM_linear_solver_params* NSM_linearSolverParams(NumericsMatrix* A);


  void NSM_fix_csc(CSparseMatrix* A);


  unsigned NSM_origin(const NumericsSparseMatrix* M);


  CSparseMatrix* NSM_get_origin(const NumericsSparseMatrix* M);

  void NSM_write_in_file(const NumericsSparseMatrix* m, FILE* file);


  NumericsSparseMatrix* NSM_new_from_file(FILE *file);



  int NSM_to_dense(const NumericsSparseMatrix * const A, double * B);


#if defined(__cplusplus) && !defined(BUILD_AS_CPP)
}
#endif

#endif