Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
a
b
c
f
g
i
k
m
n
o
p
r
s
w
Typedefs
a
b
c
d
e
f
g
h
i
l
m
o
p
q
t
v
Enumerations
Enumerator
d
h
m
n
r
s
t
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
i
j
k
l
m
o
p
q
r
s
t
u
v
Enumerations
Enumerator
a
i
l
n
o
p
s
u
v
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
v
w
Variables
a
b
c
g
h
i
m
p
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Macros
c
d
f
g
h
i
k
m
n
o
p
q
r
s
t
u
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
index.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <cassert>
23
#include <cstddef>
24
#include <iterator>
25
#include <numeric>
26
#include <stdexcept>
27
28
#include "
Vector.hpp
"
29
30
namespace
Utils
{
31
32
enum class
MemoryOrder
{
COLUMN_MAJOR
,
ROW_MAJOR
};
33
34
/** get the linear index from the position (@p a,@p b,@p c) in a 3D grid
35
* of dimensions @p adim.
36
*
37
* @return The linear index
38
* @param a , b , c Position in 3D space
39
* @param adim Dimensions of the underlying grid
40
* @param memory_order Row- or column-major
41
*/
42
inline
int
43
get_linear_index
(
int
a,
int
b,
int
c,
const
Vector3i
&
adim
,
44
MemoryOrder
memory_order =
MemoryOrder::COLUMN_MAJOR
) {
45
assert
((a >= 0) && (a <
adim
[0]));
46
assert
((b >= 0) && (b <
adim
[1]));
47
assert
((c >= 0) && (c <
adim
[2]));
48
49
if
(memory_order ==
MemoryOrder::COLUMN_MAJOR
) {
50
return
a +
adim
[0] * (b +
adim
[1] * c);
51
}
52
return
adim
[1] *
adim
[2] * a +
adim
[2] * b + c;
53
}
43
get_linear_index
(
int
a,
int
b,
int
c,
const
Vector3i
&
adim
, {
…
}
54
55
inline
int
56
get_linear_index
(
const
Vector3i
&ind,
const
Vector3i
&
adim
,
57
MemoryOrder
memory_order =
MemoryOrder::COLUMN_MAJOR
) {
58
return
get_linear_index
(ind[0], ind[1], ind[2],
adim
, memory_order);
59
}
56
get_linear_index
(
const
Vector3i
&ind,
const
Vector3i
&
adim
, {
…
}
60
61
/**
62
* @brief Linear index into a lower triangular matrix.
63
*
64
* This is row-major.
65
*
66
* @tparam T Integral type
67
* @param i row index
68
* @param j column index
69
* @return linear index
70
*/
71
template
<
class
T> T
lower_triangular
(T i, T
j
) {
72
/* i is a valid row index */
73
assert
(i >= 0);
74
/* j is in the lower triangle */
75
assert
(
j
>= 0
and
j
<= i);
76
return
(i * (i + 1)) / 2 +
j
;
77
}
71
template
<
class
T> T
lower_triangular
(T i, T
j
) {
…
}
78
79
}
// namespace Utils
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
Utils::Vector
Definition
Vector.hpp:49
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
Utils
Definition
Variant.hpp:40
Utils::get_linear_index
int get_linear_index(int a, int b, int c, const Vector3i &adim, MemoryOrder memory_order=MemoryOrder::COLUMN_MAJOR)
get the linear index from the position (a,b,c) in a 3D grid of dimensions adim.
Definition
index.hpp:43
Utils::lower_triangular
T lower_triangular(T i, T j)
Linear index into a lower triangular matrix.
Definition
index.hpp:71
Utils::MemoryOrder
MemoryOrder
Definition
index.hpp:32
Utils::MemoryOrder::ROW_MAJOR
@ ROW_MAJOR
Utils::MemoryOrder::COLUMN_MAJOR
@ COLUMN_MAJOR
src
utils
include
utils
index.hpp
Generated on Sat Apr 19 2025 01:15:00 for ESPResSo by
1.9.8