Compare commits
10 Commits
janitaws/f
...
coryab/cre
| Author | SHA1 | Date | |
|---|---|---|---|
| aa5746b2a6 | |||
| 86e7d3acb1 | |||
| e5431ebce8 | |||
| 5a0dbb94f7 | |||
| 53b1bfcda7 | |||
| b80220f3e7 | |||
| 751f356498 | |||
| 88f2d8d28d | |||
| 93d4687b8f | |||
| 34ff8a6ab9 |
14
README.md
14
README.md
@@ -4,6 +4,20 @@
|
|||||||
|
|
||||||
- [Project](https://anderkve.github.io/FYS3150/book/projects/project2.html)
|
- [Project](https://anderkve.github.io/FYS3150/book/projects/project2.html)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
To compile the C++ programs, you need to have these packages installed:
|
||||||
|
|
||||||
|
- Armadillo
|
||||||
|
- Openmp
|
||||||
|
|
||||||
|
To run the Python scripts, you need to have these packages:
|
||||||
|
|
||||||
|
- numpy
|
||||||
|
- matplotlib
|
||||||
|
- pandas
|
||||||
|
- seaborn
|
||||||
|
|
||||||
## Compile and run C++ programs
|
## Compile and run C++ programs
|
||||||
|
|
||||||
Compiling and linking is done using Make, make sure you are in the root directory.
|
Compiling and linking is done using Make, make sure you are in the root directory.
|
||||||
|
|||||||
@@ -79,7 +79,10 @@ $(function() {
|
|||||||
<a href="#details">More...</a></p>
|
<a href="#details">More...</a></p>
|
||||||
<div class="textblock"><code>#include <cassert></code><br />
|
<div class="textblock"><code>#include <cassert></code><br />
|
||||||
<code>#include <cmath></code><br />
|
<code>#include <cmath></code><br />
|
||||||
|
<code>#include <ctime></code><br />
|
||||||
<code>#include <iostream></code><br />
|
<code>#include <iostream></code><br />
|
||||||
|
<code>#include <omp.h></code><br />
|
||||||
|
<code>#include <ostream></code><br />
|
||||||
<code>#include "<a class="el" href="utils_8hpp_source.html">utils.hpp</a>"</code><br />
|
<code>#include "<a class="el" href="utils_8hpp_source.html">utils.hpp</a>"</code><br />
|
||||||
<code>#include "<a class="el" href="matrix_8hpp_source.html">matrix.hpp</a>"</code><br />
|
<code>#include "<a class="el" href="matrix_8hpp_source.html">matrix.hpp</a>"</code><br />
|
||||||
<code>#include "<a class="el" href="jacobi_8hpp_source.html">jacobi.hpp</a>"</code><br />
|
<code>#include "<a class="el" href="jacobi_8hpp_source.html">jacobi.hpp</a>"</code><br />
|
||||||
@@ -101,7 +104,7 @@ int </td><td class="memItemRight" valign="bottom"><b>main</b> ()</td></tr>
|
|||||||
</table>
|
</table>
|
||||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||||
<div class="textblock"><p>Main program for Project 2. </p>
|
<div class="textblock"><p>Main program for Project 2. </p>
|
||||||
<p>The program performs the Jacobi rotation method. The size of the matrix, and number of transformations performed are written to file. Eigenvector correstonding to the 3 smallest eigenvalues for matrices of size 6x6 and 100x100 are written to file.</p>
|
<p>The program performs the Jacobi rotation method. The size of the matrix, and number of transformations performed are written to file. Eigenvector corresponding to the 3 smallest eigenvalues for matrices of size 6x6 and 100x100 are written to file.</p>
|
||||||
<dl class="section author"><dt>Author</dt><dd>Cory Alexander Balaton (coryab) </dd>
|
<dl class="section author"><dt>Author</dt><dd>Cory Alexander Balaton (coryab) </dd>
|
||||||
<dd>
|
<dd>
|
||||||
Janita Ovidie Sandtrøen Willumsen (janitaws) </dd></dl>
|
Janita Ovidie Sandtrøen Willumsen (janitaws) </dd></dl>
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ $(function() {
|
|||||||
<p>Function prototypes for creating tridiagonal matrices.
|
<p>Function prototypes for creating tridiagonal matrices.
|
||||||
<a href="#details">More...</a></p>
|
<a href="#details">More...</a></p>
|
||||||
<div class="textblock"><code>#include <armadillo></code><br />
|
<div class="textblock"><code>#include <armadillo></code><br />
|
||||||
|
<code>#include <omp.h></code><br />
|
||||||
</div>
|
</div>
|
||||||
<p><a href="matrix_8hpp_source.html">Go to the source code of this file.</a></p>
|
<p><a href="matrix_8hpp_source.html">Go to the source code of this file.</a></p>
|
||||||
<table class="memberdecls">
|
<table class="memberdecls">
|
||||||
|
|||||||
@@ -81,22 +81,23 @@ $(function() {
|
|||||||
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="preprocessor">#define __MATRIX__</span></div>
|
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="preprocessor">#define __MATRIX__</span></div>
|
||||||
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> </div>
|
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> </div>
|
||||||
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#include <armadillo></span></div>
|
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#include <armadillo></span></div>
|
||||||
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> </div>
|
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#include <omp.h></span></div>
|
||||||
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a>(</div>
|
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> </div>
|
||||||
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> <span class="keyword">const</span> arma::vec& a, </div>
|
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a>(</div>
|
||||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">const</span> arma::vec& d, </div>
|
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">const</span> arma::vec& a, </div>
|
||||||
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <span class="keyword">const</span> arma::vec& e);</div>
|
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <span class="keyword">const</span> arma::vec& d, </div>
|
||||||
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
|
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> <span class="keyword">const</span> arma::vec& e);</div>
|
||||||
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">double</span> a, <span class="keywordtype">double</span> d, <span class="keywordtype">double</span> e);</div>
|
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> </div>
|
||||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> </div>
|
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">double</span> a, <span class="keywordtype">double</span> d, <span class="keywordtype">double</span> e);</div>
|
||||||
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#a564688c96a8e4282e995a0663545d627">create_symmetric_tridiagonal</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">double</span> a, <span class="keywordtype">double</span> d);</div>
|
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> </div>
|
||||||
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> </div>
|
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span>arma::mat <a class="code hl_function" href="matrix_8hpp.html#a564688c96a8e4282e995a0663545d627">create_symmetric_tridiagonal</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">double</span> a, <span class="keywordtype">double</span> d);</div>
|
||||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span><span class="keywordtype">double</span> <a class="code hl_function" href="matrix_8hpp.html#af42e501cbf71bec9c77ececc22723df9">max_offdiag_symmetric</a>(arma::mat& A, <span class="keywordtype">int</span>& k, <span class="keywordtype">int</span>& l);</div>
|
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
|
||||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
|
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span><span class="keywordtype">double</span> <a class="code hl_function" href="matrix_8hpp.html#af42e501cbf71bec9c77ececc22723df9">max_offdiag_symmetric</a>(arma::mat& A, <span class="keywordtype">int</span>& k, <span class="keywordtype">int</span>& l);</div>
|
||||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span><span class="preprocessor">#endif</span></div>
|
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
|
||||||
<div class="ttc" id="amatrix_8hpp_html_a564688c96a8e4282e995a0663545d627"><div class="ttname"><a href="matrix_8hpp.html#a564688c96a8e4282e995a0663545d627">create_symmetric_tridiagonal</a></div><div class="ttdeci">arma::mat create_symmetric_tridiagonal(int n, double a, double d)</div><div class="ttdoc">Create a symmetric tridiagonal matrix.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:44</div></div>
|
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span><span class="preprocessor">#endif</span></div>
|
||||||
|
<div class="ttc" id="amatrix_8hpp_html_a564688c96a8e4282e995a0663545d627"><div class="ttname"><a href="matrix_8hpp.html#a564688c96a8e4282e995a0663545d627">create_symmetric_tridiagonal</a></div><div class="ttdeci">arma::mat create_symmetric_tridiagonal(int n, double a, double d)</div><div class="ttdoc">Create a symmetric tridiagonal matrix.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:45</div></div>
|
||||||
<div class="ttc" id="amatrix_8hpp_html_aa524feaf9f44790470df4cb99bb714af"><div class="ttname"><a href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a></div><div class="ttdeci">arma::mat create_tridiagonal(const arma::vec &a, const arma::vec &d, const arma::vec &e)</div><div class="ttdoc">Create a tridiagonal matrix.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:12</div></div>
|
<div class="ttc" id="amatrix_8hpp_html_aa524feaf9f44790470df4cb99bb714af"><div class="ttname"><a href="matrix_8hpp.html#aa524feaf9f44790470df4cb99bb714af">create_tridiagonal</a></div><div class="ttdeci">arma::mat create_tridiagonal(const arma::vec &a, const arma::vec &d, const arma::vec &e)</div><div class="ttdoc">Create a tridiagonal matrix.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:12</div></div>
|
||||||
<div class="ttc" id="amatrix_8hpp_html_af42e501cbf71bec9c77ececc22723df9"><div class="ttname"><a href="matrix_8hpp.html#af42e501cbf71bec9c77ececc22723df9">max_offdiag_symmetric</a></div><div class="ttdeci">double max_offdiag_symmetric(arma::mat &A, int &k, int &l)</div><div class="ttdoc">Find the off-diagonal element with the largest absolute value.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:49</div></div>
|
<div class="ttc" id="amatrix_8hpp_html_af42e501cbf71bec9c77ececc22723df9"><div class="ttname"><a href="matrix_8hpp.html#af42e501cbf71bec9c77ececc22723df9">max_offdiag_symmetric</a></div><div class="ttdeci">double max_offdiag_symmetric(arma::mat &A, int &k, int &l)</div><div class="ttdoc">Find the off-diagonal element with the largest absolute value.</div><div class="ttdef"><b>Definition:</b> matrix.cpp:50</div></div>
|
||||||
</div><!-- fragment --></div><!-- contents -->
|
</div><!-- fragment --></div><!-- contents -->
|
||||||
<!-- start footer part -->
|
<!-- start footer part -->
|
||||||
<hr class="footer"/><address class="footer"><small>
|
<hr class="footer"/><address class="footer"><small>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define __MATRIX__
|
#define __MATRIX__
|
||||||
|
|
||||||
#include <armadillo>
|
#include <armadillo>
|
||||||
|
#include <omp.h>
|
||||||
|
|
||||||
/** @brief Create a tridiagonal matrix.
|
/** @brief Create a tridiagonal matrix.
|
||||||
*
|
*
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
x,Vector 1,Vector 2,Vector 3,Analytic 1,Analytic 2,Analytic 3
|
|
||||||
0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00
|
|
||||||
1.4285714286e-01,2.3192061397e-01,-4.1790650593e-01,-5.2112088916e-01,2.3192061392e-01,-4.1790650594e-01,-5.2112088917e-01
|
|
||||||
2.8571428571e-01,4.1790650598e-01,-5.2112088916e-01,-2.3192061388e-01,4.1790650594e-01,-5.2112088917e-01,-2.3192061392e-01
|
|
||||||
4.2857142857e-01,5.2112088920e-01,-2.3192061385e-01,4.1790650595e-01,5.2112088917e-01,-2.3192061392e-01,4.1790650594e-01
|
|
||||||
5.7142857143e-01,5.2112088915e-01,2.3192061400e-01,4.1790650592e-01,5.2112088917e-01,2.3192061392e-01,4.1790650594e-01
|
|
||||||
7.1428571429e-01,4.1790650588e-01,5.2112088921e-01,-2.3192061394e-01,4.1790650594e-01,5.2112088917e-01,-2.3192061392e-01
|
|
||||||
8.5714285714e-01,2.3192061389e-01,4.1790650591e-01,-5.2112088921e-01,2.3192061392e-01,4.1790650594e-01,-5.2112088917e-01
|
|
||||||
1.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00,0.0000000000e+00
|
|
||||||
|
@@ -1,97 +1,97 @@
|
|||||||
N,T
|
N,T
|
||||||
5,32
|
5,32
|
||||||
6,53
|
6,51
|
||||||
7,73
|
7,68
|
||||||
8,98
|
8,103
|
||||||
9,130
|
9,127
|
||||||
10,157
|
10,160
|
||||||
11,201
|
11,199
|
||||||
12,254
|
12,248
|
||||||
13,293
|
13,281
|
||||||
14,349
|
14,346
|
||||||
15,394
|
15,406
|
||||||
16,458
|
16,459
|
||||||
17,518
|
17,530
|
||||||
18,587
|
18,593
|
||||||
19,649
|
19,659
|
||||||
20,740
|
20,742
|
||||||
21,827
|
21,839
|
||||||
22,911
|
22,892
|
||||||
23,999
|
23,982
|
||||||
24,1073
|
24,1087
|
||||||
25,1187
|
25,1168
|
||||||
26,1299
|
26,1264
|
||||||
27,1410
|
27,1385
|
||||||
28,1502
|
28,1463
|
||||||
29,1604
|
29,1615
|
||||||
30,1725
|
30,1715
|
||||||
31,1856
|
31,1850
|
||||||
32,1979
|
32,1971
|
||||||
33,2089
|
33,2106
|
||||||
34,2227
|
34,2211
|
||||||
35,2383
|
35,2384
|
||||||
36,2536
|
36,2501
|
||||||
37,2644
|
37,2674
|
||||||
38,2810
|
38,2836
|
||||||
39,3000
|
39,3007
|
||||||
40,3138
|
40,3118
|
||||||
41,3299
|
41,3262
|
||||||
42,3445
|
42,3476
|
||||||
43,3638
|
43,3616
|
||||||
44,3828
|
44,3836
|
||||||
45,4015
|
45,3987
|
||||||
46,4143
|
46,4219
|
||||||
47,4348
|
47,4360
|
||||||
48,4611
|
48,4593
|
||||||
49,4773
|
49,4747
|
||||||
50,4994
|
50,4957
|
||||||
51,5163
|
51,5185
|
||||||
52,5363
|
52,5344
|
||||||
53,5586
|
53,5602
|
||||||
54,5784
|
54,5790
|
||||||
55,6075
|
55,6069
|
||||||
56,6275
|
56,6271
|
||||||
57,6550
|
57,6473
|
||||||
58,6711
|
58,6764
|
||||||
59,6957
|
59,6957
|
||||||
60,7225
|
60,7235
|
||||||
61,7483
|
61,7514
|
||||||
62,7782
|
62,7675
|
||||||
63,7952
|
63,7985
|
||||||
64,8265
|
64,8242
|
||||||
65,8531
|
65,8534
|
||||||
66,8764
|
66,8718
|
||||||
67,9060
|
67,8997
|
||||||
68,9331
|
68,9330
|
||||||
69,9686
|
69,9602
|
||||||
70,9913
|
70,9930
|
||||||
71,10098
|
71,10181
|
||||||
72,10417
|
72,10451
|
||||||
73,10795
|
73,10812
|
||||||
74,11108
|
74,11076
|
||||||
75,11342
|
75,11364
|
||||||
76,11703
|
76,11719
|
||||||
77,12104
|
77,12054
|
||||||
78,12356
|
78,12368
|
||||||
79,12623
|
79,12654
|
||||||
80,13066
|
80,13032
|
||||||
81,13513
|
81,13392
|
||||||
82,13706
|
82,13736
|
||||||
83,13998
|
83,14043
|
||||||
84,14333
|
84,14408
|
||||||
85,14694
|
85,14682
|
||||||
86,15160
|
86,15134
|
||||||
87,15470
|
87,15503
|
||||||
88,15845
|
88,15850
|
||||||
89,16211
|
89,16246
|
||||||
90,16551
|
90,16565
|
||||||
91,17047
|
91,16993
|
||||||
92,17237
|
92,17336
|
||||||
93,17669
|
93,17636
|
||||||
94,18055
|
94,18073
|
||||||
95,18614
|
95,18461
|
||||||
96,18838
|
96,18968
|
||||||
97,19253
|
97,19335
|
||||||
98,19868
|
98,19709
|
||||||
99,20092
|
99,20207
|
||||||
100,20517
|
100,20593
|
||||||
|
|||||||
|
@@ -6,7 +6,7 @@ N,T
|
|||||||
9,135
|
9,135
|
||||||
10,177
|
10,177
|
||||||
11,222
|
11,222
|
||||||
12,238
|
12,264
|
||||||
13,305
|
13,305
|
||||||
14,335
|
14,335
|
||||||
15,417
|
15,417
|
||||||
|
|||||||
|
@@ -6,6 +6,7 @@ LIBOBJS=$(LIBSRCS:.cpp=.o)
|
|||||||
INCLUDE=../include
|
INCLUDE=../include
|
||||||
|
|
||||||
CFLAGS=-larmadillo -llapack -std=c++11
|
CFLAGS=-larmadillo -llapack -std=c++11
|
||||||
|
OPENMP=-fopenmp
|
||||||
|
|
||||||
# Add a debug flag when compiling (For the DEBUG macro in utils.hpp)
|
# Add a debug flag when compiling (For the DEBUG macro in utils.hpp)
|
||||||
DEBUG ?= 0
|
DEBUG ?= 0
|
||||||
@@ -22,14 +23,14 @@ all: test_suite main
|
|||||||
|
|
||||||
# Rules for executables
|
# Rules for executables
|
||||||
main: main.o $(LIBOBJS)
|
main: main.o $(LIBOBJS)
|
||||||
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE)
|
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
|
||||||
|
|
||||||
test_suite: test_suite.o $(LIBOBJS)
|
test_suite: test_suite.o $(LIBOBJS)
|
||||||
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE)
|
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
|
||||||
|
|
||||||
# Rule for object files
|
# Rule for object files
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CC) -c $^ -o $@ $(DBGFLAG) -I$(INCLUDE)
|
$(CC) -c $^ -o $@ $(DBGFLAG) -I$(INCLUDE) $(OPENMP)
|
||||||
|
|
||||||
# Make documentation
|
# Make documentation
|
||||||
doxygen:
|
doxygen:
|
||||||
|
|||||||
15
src/main.cpp
15
src/main.cpp
@@ -4,8 +4,8 @@
|
|||||||
* The program performs the Jacobi rotation method.
|
* The program performs the Jacobi rotation method.
|
||||||
* The size of the matrix, and number of transformations
|
* The size of the matrix, and number of transformations
|
||||||
* performed are written to file.
|
* performed are written to file.
|
||||||
* Eigenvector correstonding to the 3 smallest eigenvalues
|
* Eigenvector corresponding to the 3 smallest eigenvalues
|
||||||
* for matrices of size 6x6 and 100x100 are written to file.
|
* for matrices of size 10x10 and 100x100 are written to file.
|
||||||
*
|
*
|
||||||
* @author Cory Alexander Balaton (coryab)
|
* @author Cory Alexander Balaton (coryab)
|
||||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||||
@@ -13,7 +13,10 @@
|
|||||||
*/
|
*/
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <omp.h>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "matrix.hpp"
|
#include "matrix.hpp"
|
||||||
@@ -28,6 +31,7 @@ void write_transformation_dense(int N)
|
|||||||
ofile << "N,T" << std::endl;
|
ofile << "N,T" << std::endl;
|
||||||
|
|
||||||
// Increase size of matrix, start at 5 to avoid logic_error of N=4
|
// Increase size of matrix, start at 5 to avoid logic_error of N=4
|
||||||
|
#pragma omp parallel for ordered schedule(static, 1)
|
||||||
for (int i = 5; i <= N; i++) {
|
for (int i = 5; i <= N; i++) {
|
||||||
arma::mat A = arma::mat(i, i).randn();
|
arma::mat A = arma::mat(i, i).randn();
|
||||||
A = arma::symmatu(A);
|
A = arma::symmatu(A);
|
||||||
@@ -40,8 +44,11 @@ void write_transformation_dense(int N)
|
|||||||
jacobi_eigensolver(A, 10e-14, eigval, eigvec, 100000, iters, converged);
|
jacobi_eigensolver(A, 10e-14, eigval, eigvec, 100000, iters, converged);
|
||||||
|
|
||||||
// Write size, and number of iterations to file
|
// Write size, and number of iterations to file
|
||||||
|
#pragma omp ordered
|
||||||
|
{
|
||||||
ofile << i << "," << iters << std::endl;
|
ofile << i << "," << iters << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ofile.close();
|
ofile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +65,7 @@ void write_transformation_tridiag(int N)
|
|||||||
ofile << "N,T" << std::endl;
|
ofile << "N,T" << std::endl;
|
||||||
|
|
||||||
// Increase size of matrix, start at 5 to avoid logic_error of N=4
|
// Increase size of matrix, start at 5 to avoid logic_error of N=4
|
||||||
|
#pragma omp parallel for ordered schedule(static, 1)
|
||||||
for (int i = 5; i <= N; i++) {
|
for (int i = 5; i <= N; i++) {
|
||||||
h = 1. / (double) (i+1);
|
h = 1. / (double) (i+1);
|
||||||
a = -1. / (h*h), d = 2. / (h*h);
|
a = -1. / (h*h), d = 2. / (h*h);
|
||||||
@@ -72,8 +80,11 @@ void write_transformation_tridiag(int N)
|
|||||||
jacobi_eigensolver(A, 10e-14, eigval, eigvec, 100000, iters, converged);
|
jacobi_eigensolver(A, 10e-14, eigval, eigvec, 100000, iters, converged);
|
||||||
|
|
||||||
// Write size, and number of iterations to file
|
// Write size, and number of iterations to file
|
||||||
|
#pragma omp ordered
|
||||||
|
{
|
||||||
ofile << i << "," << iters << std::endl;
|
ofile << i << "," << iters << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ofile.close();
|
ofile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ arma::mat create_tridiagonal(
|
|||||||
A(0, 0) = d(0);
|
A(0, 0) = d(0);
|
||||||
A(0, 1) = e(0);
|
A(0, 1) = e(0);
|
||||||
|
|
||||||
|
#pragma omp parallel for if(n > 50)
|
||||||
for (int i = 1; i < n-1; i++) {
|
for (int i = 1; i < n-1; i++) {
|
||||||
A(i, i-1) = a(i-1);
|
A(i, i-1) = a(i-1);
|
||||||
A(i, i) = d(i);
|
A(i, i) = d(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user