forked from michael-lehn/FLENS
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_cpp.cpp
47 lines (29 loc) · 985 Bytes
/
test_cpp.cpp
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
// $ g++ -std=c++11 -I. -DCXXBLAS_DEBUG -DWITH_OPENBLAS -o test_cpp test_cpp.cpp -L/usr/local/opt/openblas/lib -lopenblas
#include <iostream>
#include "flens/flens.cxx"
using namespace flens;
using namespace std;
int main() {
typedef DenseVector<Array<double,IndexOptions<int,1>> > FDenseVector;
typedef DenseVector<Array<double,IndexOptions<int,0>> > CDenseVector;
typedef FDenseVector::IndexType IndexType;
FDenseVector x(4);
x = 1, 2, 3, 4;
FDenseVector a = x;
cout << "x.range() = " << x.range() << endl;
cout << "x.length() = " << x.length() << endl;
cout << "x = " << x << endl;
for (IndexType i=x.firstIndex(); i<=x.lastIndex(); ++i) {
x(i) = i*i;
}
const Underscore<IndexType> _;
//DenseVector::View y = x(_(2,4));
//y = 666;
FDenseVector::NoView z = x(_(1,2));
//z = 42;
cout << "x = " << x << endl;
//cout << "y = " << y << endl;
cout << "z = " << z << endl;
CDenseVector z2 = x(_(1,2));
return 0;
}