-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelperFunctions.html
More file actions
494 lines (362 loc) · 21 KB
/
HelperFunctions.html
File metadata and controls
494 lines (362 loc) · 21 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="UTL helper functions of dmritool" name="description" />
<meta content="Diffusion MRI, software, tool, dmritool, diffusionmritool, dmri, Spherical Polar Fourier Imaging, Spherical Polar Fourier, Sampling scheme, Uniform sampling, sphere, HARDI, Orientation Distribution Function, ODF, Ensemble Average Propagator, EAP, Diffusion Propagator, q-space, q space, visualization, spherical function, spherical harmonics" name="keywords" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UTL HelperFunctions — DMRITool</title>
<link rel="shortcut icon" href="_static/linux-icon.png"/>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="DMRITool" href="index.html"/>
<link rel="up" title="Code Modules" href="codemodules.html"/>
<link rel="prev" title="Code Modules" href="codemodules.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> DMRITool
</a>
<div class="version">
v0.1.1-139-g860d86b4
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="news.html">News</a></li>
<li class="toctree-l1"><a class="reference internal" href="building.html">Building</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="userguide.html">User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="commands/commandlist.html">Command List</a></li>
<li class="toctree-l1"><a class="reference internal" href="matlabfiles/matlabfunctions.html">Matlab Function List</a></li>
<li class="toctree-l1"><a class="reference internal" href="support.html">Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="citation.html">Citation</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="developers.html">Developers</a></li>
<li class="toctree-l1"><a class="reference external" href="http://diffusionmritool.github.io/dmritool-doxygen">Doxygen Documentation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="codemodules.html">Code Modules</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">UTL HelperFunctions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#utl-module">UTL Module</a></li>
<li class="toctree-l3"><a class="reference internal" href="#build">Build</a></li>
<li class="toctree-l3"><a class="reference internal" href="#utl-ndarray">utl::NDArray</a></li>
<li class="toctree-l3"><a class="reference internal" href="#file-structure-and-dependency">File structure and dependency</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">DMRITool</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="codemodules.html">Code Modules</a> »</li>
<li>UTL HelperFunctions</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/HelperFunctions.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="utl-helperfunctions">
<h1>UTL HelperFunctions<a class="headerlink" href="#utl-helperfunctions" title="Permalink to this headline">¶</a></h1>
<div class="section" id="utl-module">
<h2>UTL Module<a class="headerlink" href="#utl-module" title="Permalink to this headline">¶</a></h2>
<p>This module contains some helper functions, logging macros, debug macros,
and an N-dimensional array class implemented using <a class="reference external" href="http://en.wikipedia.org/wiki/Expression_templates">expression template</a>
with support for <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>, <a class="reference external" href="https://github.com/xianyi/OpenBLAS">OpenBlas</a>, <a class="reference external" href="https://www.netlib.org/lapack">Lapack</a> and <a class="reference external" href="http://openmp.org/wp">OpenMP</a>.</p>
<p>Although OOP is good, sometimes functional style of programming is more
attractive, and classes are too heavy for some specific tasks, e.g.
reading text lines from a file, converting a container object to another
container object. Thus we prefer using some small functions for those tasks.</p>
</div>
<div class="section" id="build">
<h2>Build<a class="headerlink" href="#build" title="Permalink to this headline">¶</a></h2>
<p>UTL module has only header files and can be used separately based on the different dependencies.
See <a class="reference internal" href="#dependency"><span class="std std-ref">file dependency</span></a>.</p>
<p>To build codes using <code class="docutils literal"><span class="pre">utl::NDArray</span></code>, you need to have <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a> or <a class="reference external" href="https://github.com/xianyi/OpenBLAS">OpenBlas</a> + <a class="reference external" href="https://www.netlib.org/lapack">Lapack</a>, and your compile needs to support <a class="reference external" href="https://en.wikipedia.org/wiki/C%2B%2B11">C++11</a>.</p>
<ul>
<li><p class="first"><a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a> is free for students, educators, academic researchers and open source contributors.
See <a class="reference external" href="https://software.intel.com/en-us/qualify-for-free-software">the free download link</a>.
<a class="reference external" href="https://github.com/xianyi/OpenBLAS">OpenBlas</a> and <a class="reference external" href="https://www.netlib.org/lapack">Lapack</a> are always free and easy to use.</p>
</li>
<li><p class="first">If you choose <a class="reference external" href="https://github.com/xianyi/OpenBLAS">OpenBlas</a> + <a class="reference external" href="https://www.netlib.org/lapack">Lapack</a>, you can use them from system repositories.
In this case, you need to set environment variables correctly.
See <a class="reference external" href="https://github.com/xianyi/OpenBLAS/wiki/faq#multi-threaded">FAQ of OpenBlas</a>.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">xianyi</span><span class="o">/</span><span class="n">OpenBLAS</span><span class="o">.</span><span class="n">git</span>
<span class="n">cd</span> <span class="n">OpenBlas</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="n">v0</span><span class="o">.</span><span class="mf">2.13</span>
<span class="n">make</span> <span class="n">BINARY</span><span class="o">=</span><span class="mi">64</span> <span class="n">USE_THREAD</span><span class="o">=</span><span class="mi">0</span> <span class="n">USE_OPENMP</span><span class="o">=</span><span class="mi">1</span> <span class="n">cc</span><span class="o">=</span><span class="n">gcc</span> <span class="n">FC</span><span class="o">=</span><span class="n">gfortran</span>
<span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="utl-ndarray">
<h2>utl::NDArray<a class="headerlink" href="#utl-ndarray" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> is an N-dimensional array based on <a class="reference external" href="http://en.wikipedia.org/wiki/Expression_templates">expression template</a>.</li>
<li><code class="docutils literal"><span class="pre">utl::NDArray<T,1></span></code> and <code class="docutils literal"><span class="pre">utl::NDArray<T,2></span></code> are more efficient than <code class="docutils literal"><span class="pre">vnl_vector<T></span></code> and <code class="docutils literal"><span class="pre">vnl_matrix<T></span></code> because</li>
</ul>
<blockquote>
<div><ul class="simple">
<li><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> is implemented based on <a class="reference external" href="https://github.com/xianyi/OpenBLAS">openblas</a>, <a class="reference external" href="https://www.netlib.org/lapack">lapack</a> or <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">mkl</a>.</li>
<li><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> uses <a class="reference external" href="http://en.wikipedia.org/wiki/Expression_templates">expression template</a> to avoid temporary copies.</li>
<li><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> uses <a class="reference external" href="https://en.wikipedia.org/wiki/C%2B%2B11#Rvalue_references_and_move_constructors">rvalue references and move constructors, move assignment from C++11</a>.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>You can run <code class="docutils literal"><span class="pre">utlVNLBlasGTest</span></code> and <code class="docutils literal"><span class="pre">utlVNLLapackGTest</span></code> to compare efficiency of <code class="docutils literal"><span class="pre">utl::NDArray</span></code> and <code class="docutils literal"><span class="pre">vnl_vector</span></code>, <code class="docutils literal"><span class="pre">vnl_matrix</span></code>.</li>
</ul>
</div>
<div class="section" id="file-structure-and-dependency">
<h2>File structure and dependency<a class="headerlink" href="#file-structure-and-dependency" title="Permalink to this headline">¶</a></h2>
<table border="1" class="docutils" id="dependency">
<colgroup>
<col width="13%" />
<col width="18%" />
<col width="69%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Files</th>
<th class="head">Dependency</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>utlSmartAssert.h</td>
<td>std</td>
<td>macros for smart assert, modified based on the <a class="reference external" href="http://www.torjo.com/code/smart_assert.zip">SMART_ASSERT library</a> by <a class="reference external" href="http://www.torjo.com/index.html">John Torjo</a>.</td>
</tr>
<tr class="row-odd"><td>utlCoreMacro.h</td>
<td>std</td>
<td>macros for print and debug</td>
</tr>
<tr class="row-even"><td>utlCore.h</td>
<td>std</td>
<td>useful functions for general purpose</td>
</tr>
<tr class="row-odd"><td>utlCore11.h</td>
<td>std, c++11 specific</td>
<td>useful functions for general purpose</td>
</tr>
<tr class="row-even"><td>utlCoreMKL.h</td>
<td>std, (mkl optional)</td>
<td>useful functions for mkl. If mkl is not found, a manual implementation is used.</td>
</tr>
<tr class="row-odd"><td>utlCommandLineParser.h</td>
<td>std</td>
<td>small but powerful command line parser, borrowed from <a class="reference external" href="http://cimg.eu/">CImg</a></td>
</tr>
<tr class="row-even"><td>utlMath.h</td>
<td>std</td>
<td>math related functions</td>
</tr>
<tr class="row-odd"><td>utlRotationMatrixFromVectors.h</td>
<td>std</td>
<td>functions to find rotation 3x3 matrix from two 3D vectors</td>
</tr>
<tr class="row-even"><td>utlSTDHeaders.h</td>
<td>std</td>
<td>macros to avoid include confliction issues for different versions of std</td>
</tr>
<tr class="row-odd"><td>utlTypeinfo.h</td>
<td>std, c++11 specific</td>
<td>type alias for c++11</td>
</tr>
<tr class="row-even"><td>utlGTest.h</td>
<td>google gtest</td>
<td>useful macros for <a class="reference external" href="https://github.com/google/googletest">gtest</a></td>
</tr>
<tr class="row-odd"><td>utl_cblas.h</td>
<td>cblas</td>
<td>header file from <code class="docutils literal"><span class="pre">cblas.h</span></code>. Add some macro conditions to avoid multiple definition issues from other versions of cblas.</td>
</tr>
<tr class="row-even"><td>utlBlas.h</td>
<td>cblas, (mkl optional)</td>
<td>templated version of interface for cblas</td>
</tr>
<tr class="row-odd"><td>utlLapack.h</td>
<td>lapack</td>
<td>templated version of interface for <code class="docutils literal"><span class="pre">lapacke</span></code></td>
</tr>
<tr class="row-even"><td>utlMKL.h</td>
<td>mkl</td>
<td>templated version of interface for <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">mkl</a></td>
</tr>
<tr class="row-odd"><td>utlExpression.h</td>
<td>std</td>
<td>Implementation of <a class="reference external" href="http://en.wikipedia.org/wiki/Expression_templates">Expression Template</a> to avoid temporary copies in expression.</td>
</tr>
<tr class="row-even"><td>utlFunctors.h</td>
<td>std</td>
<td>Some functor classes, and functions for <code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code>.</td>
</tr>
<tr class="row-odd"><td>utlNDArray.h</td>
<td>std, blas, lapack, (mkl optional)</td>
<td><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> class (N-dimensional array) based on expression template, blas and mkl.</td>
</tr>
<tr class="row-even"><td>utlVector.h</td>
<td>std, blas, lapack, (mkl optional)</td>
<td><code class="docutils literal"><span class="pre">utl::NDArray<T,1></span></code> class (vector).</td>
</tr>
<tr class="row-odd"><td>utlMatrix.h</td>
<td>std, blas, lapack, (mkl optional)</td>
<td><code class="docutils literal"><span class="pre">utl::NDArray<T,2></span></code> class (matrix).</td>
</tr>
<tr class="row-even"><td>utl4thOrderTensor.h</td>
<td>std, blas, lapack, (mkl optional)</td>
<td><code class="docutils literal"><span class="pre">utl::NDArray<T,4></span></code> class (4th order tensor).</td>
</tr>
<tr class="row-odd"><td>utlNDArrayFunctions.h</td>
<td>std, blas, lapack, (mkl optional)</td>
<td><code class="docutils literal"><span class="pre">utl::NDArray<T,N></span></code> related functions.</td>
</tr>
<tr class="row-even"><td>utlDMRI.h</td>
<td>std, <code class="docutils literal"><span class="pre">utl::NDArray</span></code></td>
<td>Useful functions for dMRI</td>
</tr>
<tr class="row-odd"><td>utlDMRIStoredTables.h</td>
<td>std, <code class="docutils literal"><span class="pre">utl::NDArray</span></code></td>
<td>Precomputed tables for dmritool</td>
</tr>
<tr class="row-even"><td>utlOpenMP.h</td>
<td>openmp</td>
<td><a class="reference external" href="http://openmp.org/wp">openmp</a> related functions</td>
</tr>
<tr class="row-odd"><td>utlVNL.h</td>
<td>vnl</td>
<td>vnl related functions</td>
</tr>
<tr class="row-even"><td>utlVNLBlas.h</td>
<td>vnl, blas</td>
<td>useful functions for vnl vector and matrix using blas implementation</td>
</tr>
<tr class="row-odd"><td>utlVNLLapack.h</td>
<td>vnl, blas, lapack</td>
<td>useful functions for vnl vector and matrix using blas and lapack implementation</td>
</tr>
<tr class="row-even"><td>utlVNLIO.h</td>
<td>std, vnl, blas, lapack, (mkl optional)</td>
<td>conversion between <code class="docutils literal"><span class="pre">utl::NDArray</span></code> and <code class="docutils literal"><span class="pre">vnl_vector</span></code>, <code class="docutils literal"><span class="pre">vnl_matrix</span></code></td>
</tr>
<tr class="row-odd"><td>utlITKMacro.h</td>
<td>itk</td>
<td>macros for <a class="reference external" href="http://www.itk.org">itk</a></td>
</tr>
<tr class="row-even"><td>utlITK.h</td>
<td>itk</td>
<td>functions for itk</td>
</tr>
<tr class="row-odd"><td>utlVTKMacro.h</td>
<td>vtk</td>
<td>macros for <a class="reference external" href="http://www.vtk.org">vtk</a></td>
</tr>
<tr class="row-even"><td>utl.h</td>
<td>std, itk, blas, lapack, gsl, (mkl optional)</td>
<td>useful functions for <a class="reference external" href="https://diffusionmritool.github.io">dmritool</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="codemodules.html" class="btn btn-neutral" title="Code Modules" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright DMRITool developers <dmritool-discussion@www.nitrc.org>.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'v0.1.1',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
<a href="https://github.com/DiffusionMRITool/dmritool"><img style="position: absolute; top: 0; right: 0; border: 0; width: 150px; height: 150px;"
src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67"
alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-60718632-2', 'auto');
ga('send', 'pageview');
</script>
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=11048608;
var sc_invisible=0;
var sc_security="4e279a87";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="web counter"
href="http://statcounter.com/free-hit-counter/"
target="_blank"><img class="statcounter"
src="//c.statcounter.com/11048608/0/4e279a87/0/" alt="web
counter"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->
<!-- <a href="http://statcounter.com/p11048608/?guest=1">View My -->
<!-- Stats</a> -->
</body>
</html>