-
Notifications
You must be signed in to change notification settings - Fork 41
/
array_helper.h
42 lines (31 loc) · 1.01 KB
/
array_helper.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
/*
* array_helper.h
* peer
*
* Created by Oliver Stegle on 12/28/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#ifndef __ARRAY_HELPER_H__
#define __ARRAY_HELPER_H__
#include <Eigen/Eigen>
#include "alglib/src/ap.h"
using namespace Eigen;
using alglib::randomreal;
//some definitions for the python interface
#define float64_t double
#define float32_t float
#define int32_t int
//standard Matrix type to use in this project
typedef Matrix<float32_t, Dynamic, Dynamic> PMatrix;
typedef Matrix<float32_t, Dynamic, 1> PVector;
//array 2 matrix and vice versa
PMatrix array2matrix(const float32_t* matrix,int32_t rows,int32_t cols);
PMatrix array2matrix(const float64_t* matrix,int32_t rows,int32_t cols);
void matrix2array(const PMatrix m,float32_t** matrix, int32_t* rows, int32_t*cols);
void matrix2array(const PMatrix m,float64_t** matrix, int32_t* rows, int32_t*cols);
//check for null Matrix (empty)
bool isnull(const PMatrix m);
//create random matrix:
PMatrix randn(int n, int m);
#endif