Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
54ef91e0
Commit
54ef91e0
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
clang-format Base/
parent
a19bda45
No related branches found
No related tags found
1 merge request
!486
Merge BasicVector3D into Vectors3D.h, make it header only, and decouple from Complex.h
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Base/Math/Functions.cpp
+1
-1
1 addition, 1 deletion
Base/Math/Functions.cpp
Base/Vector/Vectors3D.h
+10
-19
10 additions, 19 deletions
Base/Vector/Vectors3D.h
with
11 additions
and
20 deletions
Base/Math/Functions.cpp
+
1
−
1
View file @
54ef91e0
...
@@ -51,7 +51,7 @@ double Math::cot(double x)
...
@@ -51,7 +51,7 @@ double Math::cot(double x)
double
Math
::
sinc
(
double
x
)
// Sin(x)/x
double
Math
::
sinc
(
double
x
)
// Sin(x)/x
{
{
if
(
x
==
0
)
if
(
x
==
0
)
return
1
;
return
1
;
return
std
::
sin
(
x
)
/
x
;
return
std
::
sin
(
x
)
/
x
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Base/Vector/Vectors3D.h
+
10
−
19
View file @
54ef91e0
...
@@ -27,9 +27,9 @@ using C3 = Vec3<complex_t>;
...
@@ -27,9 +27,9 @@ using C3 = Vec3<complex_t>;
//! Three-dimensional vector template, for use with integer, double, or complex components.
//! Three-dimensional vector template, for use with integer, double, or complex components.
template
<
class
T
>
class
Vec3
:
public
std
::
array
<
T
,
3
>
{
template
<
class
T
>
class
Vec3
:
public
std
::
array
<
T
,
3
>
{
private:
private:
using
super
=
std
::
array
<
T
,
3
>
;
using
super
=
std
::
array
<
T
,
3
>
;
public:
public:
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
@@ -40,7 +40,7 @@ public:
...
@@ -40,7 +40,7 @@ public:
Vec3
()
:
super
{
0.
,
0.
,
0.
}
{}
Vec3
()
:
super
{
0.
,
0.
,
0.
}
{}
//! Constructs a vector from cartesian components.
//! Constructs a vector from cartesian components.
Vec3
(
const
T
x
,
const
T
y
,
const
T
z
)
:
super
{
x
,
y
,
z
}
{}
Vec3
(
const
T
x
,
const
T
y
,
const
T
z
)
:
super
{
x
,
y
,
z
}
{}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Component access
// Component access
...
@@ -162,10 +162,7 @@ public:
...
@@ -162,10 +162,7 @@ public:
double
angle
(
const
Vec3
<
T
>&
v
)
const
;
double
angle
(
const
Vec3
<
T
>&
v
)
const
;
//! Returns projection of this onto other vector: (this*v)*v/|v|^2.
//! Returns projection of this onto other vector: (this*v)*v/|v|^2.
Vec3
<
T
>
project
(
const
Vec3
<
T
>&
v
)
const
Vec3
<
T
>
project
(
const
Vec3
<
T
>&
v
)
const
{
return
dot
(
v
)
*
v
/
v
.
mag2
();
}
{
return
dot
(
v
)
*
v
/
v
.
mag2
();
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Rotations
// Rotations
...
@@ -219,16 +216,14 @@ template <class T> inline Vec3<T> operator-(const Vec3<T>& v)
...
@@ -219,16 +216,14 @@ template <class T> inline Vec3<T> operator-(const Vec3<T>& v)
//! Addition of two vectors.
//! Addition of two vectors.
//! @relates Vec3
//! @relates Vec3
template
<
class
T
>
template
<
class
T
>
inline
Vec3
<
T
>
operator
+
(
const
Vec3
<
T
>&
a
,
const
Vec3
<
T
>&
b
)
inline
Vec3
<
T
>
operator
+
(
const
Vec3
<
T
>&
a
,
const
Vec3
<
T
>&
b
)
{
{
return
{
a
.
x
()
+
b
.
x
(),
a
.
y
()
+
b
.
y
(),
a
.
z
()
+
b
.
z
()};
return
{
a
.
x
()
+
b
.
x
(),
a
.
y
()
+
b
.
y
(),
a
.
z
()
+
b
.
z
()};
}
}
//! Subtraction of two vectors.
//! Subtraction of two vectors.
//! @relates Vec3
//! @relates Vec3
template
<
class
T
>
template
<
class
T
>
inline
Vec3
<
T
>
operator
-
(
const
Vec3
<
T
>&
a
,
const
Vec3
<
T
>&
b
)
inline
Vec3
<
T
>
operator
-
(
const
Vec3
<
T
>&
a
,
const
Vec3
<
T
>&
b
)
{
{
return
{
a
.
x
()
-
b
.
x
(),
a
.
y
()
-
b
.
y
(),
a
.
z
()
-
b
.
z
()};
return
{
a
.
x
()
-
b
.
x
(),
a
.
y
()
-
b
.
y
(),
a
.
z
()
-
b
.
z
()};
}
}
...
@@ -269,9 +264,7 @@ template <class T, class U> inline Vec3<T> operator/(const Vec3<T>& v, U a)
...
@@ -269,9 +264,7 @@ template <class T, class U> inline Vec3<T> operator/(const Vec3<T>& v, U a)
//! Returns dot product of (complex) vectors (antilinear in the first [=self] argument).
//! Returns dot product of (complex) vectors (antilinear in the first [=self] argument).
#ifndef SWIG
#ifndef SWIG
template
<
class
T
>
template
<
class
T
>
template
<
class
U
>
inline
auto
Vec3
<
T
>::
dot
(
const
Vec3
<
U
>&
v
)
const
template
<
class
U
>
inline
auto
Vec3
<
T
>::
dot
(
const
Vec3
<
U
>&
v
)
const
{
{
Vec3
<
T
>
left_star
=
this
->
conj
();
Vec3
<
T
>
left_star
=
this
->
conj
();
return
left_star
.
x
()
*
v
.
x
()
+
left_star
.
y
()
*
v
.
y
()
+
left_star
.
z
()
*
v
.
z
();
return
left_star
.
x
()
*
v
.
x
()
+
left_star
.
y
()
*
v
.
y
()
+
left_star
.
z
()
*
v
.
z
();
...
@@ -280,12 +273,10 @@ inline auto Vec3<T>::dot(const Vec3<U>& v) const
...
@@ -280,12 +273,10 @@ inline auto Vec3<T>::dot(const Vec3<U>& v) const
//! Returns cross product of (complex) vectors.
//! Returns cross product of (complex) vectors.
#ifndef SWIG
#ifndef SWIG
template
<
class
T
>
template
<
class
T
>
template
<
class
U
>
inline
auto
Vec3
<
T
>::
cross
(
const
Vec3
<
U
>&
v
)
const
template
<
class
U
>
inline
auto
Vec3
<
T
>::
cross
(
const
Vec3
<
U
>&
v
)
const
{
{
return
Vec3
<
decltype
(
this
->
x
()
*
v
.
x
())
>
(
return
Vec3
<
decltype
(
this
->
x
()
*
v
.
x
())
>
(
y
()
*
v
.
z
()
-
v
.
y
()
*
z
(),
z
()
*
v
.
x
()
-
v
.
z
()
*
x
(),
y
()
*
v
.
z
()
-
v
.
y
()
*
z
(),
z
()
*
v
.
x
()
-
v
.
z
()
*
x
(),
x
()
*
v
.
y
()
-
v
.
x
()
*
y
());
x
()
*
v
.
y
()
-
v
.
x
()
*
y
());
}
}
#endif // USER_API
#endif // USER_API
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment