ergo
files_sparse.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
38 #ifndef FILES_SPARSE_HEADER
39 #define FILES_SPARSE_HEADER
40 
41 #include "realtype.h" // definitions of types (utilities_basic)
42 
43 #include <iostream>
44 #include <fstream>
45 #include <string.h>
46 #include <assert.h>
47 #include <vector>
48 #include <sstream>
49 #include <stdexcept>
50 #include "mmio.h"
51 
52 
53 using namespace std;
54 
55 typedef ergo_real real;
56 
57 
58 /* READ SPARSE MATRIX FROM THE MATRIX MARKET FILE */
59 int read_matrix_from_mtx(const char* filename, vector<int> &I, vector<int> &J, vector<real> &val, int &N, int &M);
60 
61 
62 /* WRITE SPARSE MATRIX TO THE MATRIX MARKET FILE */
63 int write_matrix_to_mtx(const char* filename, const vector<int> &I, const vector<int> &J, const vector<real> &val, const int &N);
64 int write_matrix_to_mtx_nonsymm(const char* filename, const vector<int> &I, const vector<int> &J, const vector<real> &val, const int &N, const int &M);
65 
66 #endif //FILES_SPARSE_HEADER
67 
68 
69 
70 
mm_typecode_to_str
char * mm_typecode_to_str(MM_typecode matcode)
Definition: mmio.c:488
files_sparse.h
File containing declarations of functions for reading/writing sparse matrices from/to mtx (MatrixMark...
realtype.h
Definition of the main floating-point datatype used; the ergo_real type.
mm_set_sparse
#define mm_set_sparse(typecode)
Definition: mmio.h:93
ergo_real
double ergo_real
Definition: realtype.h:69
read_matrix_from_mtx
int read_matrix_from_mtx(const char *filename, std::vector< int > &I, vector< int > &J, vector< real > &val, int &N, int &M)
Definition: files_sparse.cc:48
mm_set_real
#define mm_set_real(typecode)
Definition: mmio.h:96
mm_read_mtx_crd_size
int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz)
Definition: mmio.c:222
mmio.h
Matrix Market I/O library for ANSI C. See http://math.nist.gov/MatrixMarket for details.
real
ergo_real real
Definition: test.cc:46
mm_set_general
#define mm_set_general(typecode)
Definition: mmio.h:102
mm_is_symmetric
#define mm_is_symmetric(typecode)
Definition: mmio.h:79
mm_write_mtx_crd_size
int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz)
Definition: mmio.c:214
write_matrix_to_mtx
int write_matrix_to_mtx(const char *filename, const vector< int > &I, const vector< int > &J, const vector< real > &val, const int &N)
Definition: files_sparse.cc:151
mm_set_matrix
#define mm_set_matrix(typecode)
Definition: mmio.h:89
MM_typecode
char MM_typecode[4]
Definition: mmio.h:52
mm_is_matrix
#define mm_is_matrix(typecode)
Definition: mmio.h:67
mm_write_banner
int mm_write_banner(FILE *f, MM_typecode matcode)
Definition: mmio.c:419
write_matrix_to_mtx_nonsymm
int write_matrix_to_mtx_nonsymm(const char *filename, const vector< int > &I, const vector< int > &J, const vector< real > &val, const int &N, const int &M)
Definition: files_sparse.cc:192
mm_set_symmetric
#define mm_set_symmetric(typecode)
Definition: mmio.h:101
mm_is_complex
#define mm_is_complex(typecode)
Definition: mmio.h:74
read_matrix_from_mtx
int read_matrix_from_mtx(const char *filename, vector< int > &I, vector< int > &J, vector< real > &val, int &N, int &M)
real
ergo_real real
Definition: files_sparse.h:55
mm_initialize_typecode
#define mm_initialize_typecode(typecode)
Definition: mmio.h:109
mm_read_banner
int mm_read_banner(FILE *f, MM_typecode *matcode)
Definition: mmio.c:129
mm_set_coordinate
#define mm_set_coordinate(typecode)
Definition: mmio.h:90
write_matrix_to_mtx_nonsymm
int write_matrix_to_mtx_nonsymm(const char *filename, const vector< int > &I, const vector< int > &J, const vector< real > &val, const int &N, const int &M)
Definition: files_sparse.cc:192
write_matrix_to_mtx
int write_matrix_to_mtx(const char *filename, const vector< int > &I, const vector< int > &J, const vector< real > &val, const int &N)
Definition: files_sparse.cc:151
mm_is_sparse
#define mm_is_sparse(typecode)
Definition: mmio.h:69
real
ergo_real real
Definition: files_sparse.cc:42