Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tobias WEBER
in20tools_old
Commits
6d637df7
Commit
6d637df7
authored
Mar 13, 2019
by
Tobias WEBER
Browse files
function to check if space groups operations are equal
parent
2fffa979
Changes
4
Hide whitespace changes
Inline
Side-by-side
libs/_cxx20/math_algos.h
View file @
6d637df7
...
...
@@ -419,6 +419,38 @@ requires is_mat<t_mat>
}
/**
* check if two collections of matrices or vectors are equal
*/
template
<
class
t_obj
,
template
<
class
...
>
class
t_vec
=
std
::
vector
>
bool
equals_all
(
const
t_vec
<
t_obj
>&
vec1
,
const
t_vec
<
t_obj
>&
_vec2
,
typename
t_obj
::
value_type
eps
=
std
::
numeric_limits
<
typename
t_obj
::
value_type
>::
epsilon
())
{
auto
vec2
=
_vec2
;
if
(
vec1
.
size
()
!=
vec2
.
size
())
return
false
;
for
(
const
auto
&
obj1
:
vec1
)
{
// find obj1 in vec2
auto
iter
=
std
::
find_if
(
vec2
.
crbegin
(),
vec2
.
crend
(),
[
&
obj1
,
eps
](
const
t_obj
&
obj2
)
->
bool
{
return
m
::
equals
<
t_obj
>
(
obj1
,
obj2
,
eps
);
});
// not found
if
(
iter
==
vec2
.
crend
())
return
false
;
// remove already checked element
vec2
.
erase
(
iter
.
base
()
-
1
);
}
return
true
;
}
/**
* set submatrix to unit
*/
...
...
@@ -3788,6 +3820,7 @@ requires is_vec<t_vec> && is_mat<t_mat>
return
newatoms
;
}
// ----------------------------------------------------------------------------
...
...
tools/structfact/loadcif.h
View file @
6d637df7
...
...
@@ -62,6 +62,7 @@ std::vector<t_mat> get_cif_ops(gemmi::cif::Block& block)
/**
* gets the symmetry operations from the CIF's space group
* (use m::equals_all to check if space group operations are the same)
*/
template
<
class
t_vec
,
class
t_mat
,
class
t_real
=
typename
t_vec
::
value_type
>
std
::
vector
<
t_mat
>
get_cif_sg_ops
(
gemmi
::
cif
::
Block
&
block
)
...
...
tools/test/leastsq.cpp
View file @
6d637df7
...
...
@@ -26,8 +26,6 @@ using t_mat_cplx = m::mat<t_cplx, std::vector>;
int
main
()
{
//std::cout << m::stoval<unsigned int>("123") << std::endl;
auto
x
=
m
::
create
<
t_vec
>
({
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
});
auto
y
=
m
::
create
<
t_vec
>
({
5
,
5
,
7
,
9
,
9.5
,
10.5
,
10.5
,
12
,
13.5
,
14
});
...
...
tools/test/mat1.cpp
0 → 100644
View file @
6d637df7
/**
* math lib test
* @author Tobias Weber <tweber@ill.fr>
* @date mar-19
* @license GPLv3, see 'LICENSE' file
*
* g++-8 -std=c++17 -fconcepts -o mat1 mat1.cpp
* g++-8 -std=c++17 -fconcepts -DUSE_LAPACK -I/usr/include/lapacke -I/usr/local/opt/lapack/include -L/usr/local/opt/lapack/lib -o leastsq leastsq.cpp -llapacke
*/
#include <iostream>
#include <vector>
#include "../../libs/_cxx20/math_algos.h"
using
namespace
m_ops
;
using
t_real
=
double
;
//using t_real = float;
using
t_cplx
=
std
::
complex
<
t_real
>
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
using
t_vec_cplx
=
std
::
vector
<
t_cplx
>
;
using
t_mat_cplx
=
m
::
mat
<
t_cplx
,
std
::
vector
>
;
int
main
()
{
std
::
cout
<<
m
::
stoval
<
unsigned
int
>
(
"123"
)
<<
std
::
endl
;
std
::
vector
vec1
{{
m
::
create
<
t_vec
>
({
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
}),
m
::
create
<
t_vec
>
({
5
,
5
,
7
,
9
,
9.5
,
10.5
,
10.5
,
12
,
13.5
,
14
})
}};
std
::
vector
vec2
{{
m
::
create
<
t_vec
>
({
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10.5
}),
m
::
create
<
t_vec
>
({
5
,
5
,
7
,
9
,
9.5
,
10.5
,
10.5
,
12
,
13.5
,
14
})
}};
std
::
vector
vec3
{{
m
::
create
<
t_vec
>
({
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
10
}),
m
::
create
<
t_vec
>
({
5
,
5
,
7
,
9
,
9.5
,
10.5
,
10.5
,
12
,
13.5
,
14
,
14
})
}};
std
::
cout
<<
std
::
boolalpha
<<
m
::
equals_all
(
vec1
,
vec1
,
1e-5
)
<<
std
::
endl
;
std
::
cout
<<
std
::
boolalpha
<<
m
::
equals_all
(
vec3
,
vec3
,
1e-5
)
<<
std
::
endl
;
std
::
cout
<<
std
::
boolalpha
<<
m
::
equals_all
(
vec1
,
vec2
,
1e-5
)
<<
std
::
endl
;
std
::
cout
<<
std
::
boolalpha
<<
m
::
equals_all
(
vec1
,
vec3
,
1e-5
)
<<
std
::
endl
;
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment