planc
Parallel Lowrank Approximation with Non-negativity Constraints
utils.h
Go to the documentation of this file.
1 /* Copyright 2016 Ramakrishnan Kannan */
2 // utility functions
3 #ifndef COMMON_UTILS_H_
4 #define COMMON_UTILS_H_
5 
6 // #ifndef _VERBOSE
7 // #define _VERBOSE 1
8 // #endif
9 
11 
13 
14 // #if !defined(ARMA_64BIT_WORD)
15 // #define ARMA_64BIT_WORD
16 #define ARMA_DONT_USE_WRAPPER
17 #define ARMA_USE_BLAS
18 #define ARMA_USE_LAPACK
19 // #endif
20 #include <armadillo>
21 #include <cmath>
22 #include <iostream>
23 #include <vector>
24 
25 // using namespace std;
26 
27 #ifndef ERR
28 #define ERR std::cerr
29 #endif
30 
31 #ifndef WARN
32 #define WARN std::cerr
33 #endif
34 
35 #ifndef INFO
36 #define INFO std::cout
37 #endif
38 
39 #ifndef OUTPUT
40 #define OUTPUT std::cout
41 #endif
42 
43 #define EPSILON_1EMINUS16 0.00000000000000001
44 #define EPSILON 0.000001
45 #define EPSILON_1EMINUS12 1e-12
46 #define NUMBEROF_DECIMAL_PLACES 12
47 #define RAND_SEED 100
48 #define RAND_SEED_SPARSE 100
49 
50 // defines for namespace confusion
51 #define FMAT arma::fmat
52 #define MAT arma::mat
53 #define FROWVEC arma::frowvec
54 #define ROWVEC arma::rowvec
55 #define FVEC arma::fvec
56 #define SP_FMAT arma::sp_fmat
57 #define SP_MAT arma::sp_mat
58 #define UVEC arma::uvec
59 #define IVEC arma::ivec
60 #define UWORD arma::uword
61 #define VEC arma::vec
62 
63 #define PRINTMATINFO(A) "::" #A "::" << (A).n_rows << "x" << (A).n_cols
64 
65 #define PRINTMAT(A) PRINTMATINFO((A)) << endl << (A)
66 
67 typedef std::vector<int> STDVEC;
68 typedef unsigned int UINT;
69 typedef unsigned long ULONG;
70 
71 void absmat(const FMAT *X);
72 
73 inline void tic();
74 inline double toc();
75 
76 int random_sieve(const int);
77 
78 template <typename FVT>
79 inline void fillVector(const FVT value, std::vector<FVT> *a) {
80  for (unsigned int ii = 0; ii < a->size(); ii++) {
81  (*a)[ii] = value;
82  }
83 }
84 
85 #endif // COMMON_UTILS_H_
Definition: utils.h:12
#define FMAT
Definition: utils.h:51
Definition: utils.h:12
void tic()
start the timer. easy to call as tic(); some code; double t=toc();
Definition: utils.hpp:42
void fillVector(const FVT value, std::vector< FVT > *a)
Definition: utils.h:79
int random_sieve(const int)
Definition: utils.hpp:74
Definition: utils.h:10
algotype
Definition: utils.h:10
double toc()
Definition: utils.hpp:48
normtype
Definition: utils.h:12
Definition: utils.h:12
Definition: utils.h:10
Definition: utils.h:10
unsigned int UINT
Definition: utils.h:68
unsigned long ULONG
Definition: utils.h:69
std::vector< int > STDVEC
Definition: utils.h:67
Definition: utils.h:10
void absmat(const FMAT *X)
Definition: utils.h:10
Definition: utils.h:10