Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
1f314a5e
Commit
1f314a5e
authored
Jul 19, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removing compiler warnings on MSVC
parent
0adb50ac
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
93 deletions
+93
-93
CMakeLists.txt
+22
-22
include/cif++/matrix.hpp
+41
-41
include/cif++/symmetry.hpp
+1
-1
src/category.cpp
+4
-4
src/point.cpp
+2
-2
src/symmetry.cpp
+20
-20
src/text.cpp
+1
-1
src/utilities.cpp
+2
-2
No files found.
CMakeLists.txt
View file @
1f314a5e
...
...
@@ -98,33 +98,33 @@ if(BUILD_FOR_CCP4)
endif
()
endif
()
if
(
WIN32
)
if
(
${
CMAKE_SYSTEM_VERSION
}
GREATER_EQUAL 10
)
# Windows 10
add_definitions
(
-D _WIN32_WINNT=0x0A00
)
elseif
(
${
CMAKE_SYSTEM_VERSION
}
EQUAL 6.3
)
# Windows 8.1
add_definitions
(
-D _WIN32_WINNT=0x0603
)
elseif
(
${
CMAKE_SYSTEM_VERSION
}
EQUAL 6.2
)
# Windows 8
add_definitions
(
-D _WIN32_WINNT=0x0602
)
elseif
(
${
CMAKE_SYSTEM_VERSION
}
EQUAL 6.1
)
# Windows 7
add_definitions
(
-D _WIN32_WINNT=0x0601
)
elseif
(
${
CMAKE_SYSTEM_VERSION
}
EQUAL 6.0
)
# Windows Vista
add_definitions
(
-D _WIN32_WINNT=0x0600
)
else
()
# Windows XP (5.1)
add_definitions
(
-D _WIN32_WINNT=0x0501
)
endif
()
add_definitions
(
-DNOMINMAX
)
endif
()
if
(
MSVC
)
# make msvc standards compliant...
add_compile_options
(
/permissive-
)
macro
(
get_WIN32_WINNT version
)
if
(
CMAKE_SYSTEM_VERSION
)
set
(
ver
${
CMAKE_SYSTEM_VERSION
}
)
string
(
REGEX MATCH
"^([0-9]+).([0-9])"
ver
${
ver
}
)
string
(
REGEX MATCH
"^([0-9]+)"
verMajor
${
ver
}
)
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if
(
"
${
verMajor
}
"
MATCHES
"10"
)
set
(
verMajor
"A"
)
string
(
REGEX REPLACE
"^([0-9]+)"
${
verMajor
}
ver
${
ver
}
)
endif
()
# Remove all remaining '.' characters.
string
(
REPLACE
"."
""
ver
${
ver
}
)
# Prepend each digit with a zero.
string
(
REGEX REPLACE
"([0-9A-Z])"
"0
\\
1"
ver
${
ver
}
)
set
(
${
version
}
"0x
${
ver
}
"
)
if
(
BUILD_SHARED_LIBS
)
set
(
CMAKE_MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
)
else
()
set
(
CMAKE_MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>"
)
endif
()
endmacro
()
get_WIN32_WINNT
(
ver
)
add_definitions
(
-D_WIN32_WINNT=
${
ver
}
)
endif
()
# Libraries
...
...
include/cif++/matrix.hpp
View file @
1f314a5e
...
...
@@ -44,24 +44,24 @@ template <typename M>
class
matrix_expression
{
public
:
constexpr
uint32
_t
dim_m
()
const
{
return
static_cast
<
const
M
&>
(
*
this
).
dim_m
();
}
constexpr
uint32
_t
dim_n
()
const
{
return
static_cast
<
const
M
&>
(
*
this
).
dim_n
();
}
constexpr
size
_t
dim_m
()
const
{
return
static_cast
<
const
M
&>
(
*
this
).
dim_m
();
}
constexpr
size
_t
dim_n
()
const
{
return
static_cast
<
const
M
&>
(
*
this
).
dim_n
();
}
constexpr
bool
empty
()
const
{
return
dim_m
()
==
0
or
dim_n
()
==
0
;
}
constexpr
auto
&
operator
()(
uint32_t
i
,
uint32
_t
j
)
constexpr
auto
&
operator
()(
size_t
i
,
size
_t
j
)
{
return
static_cast
<
M
&>
(
*
this
).
operator
()(
i
,
j
);
}
constexpr
auto
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
auto
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
static_cast
<
const
M
&>
(
*
this
).
operator
()(
i
,
j
);
}
void
swap_row
(
uint32_t
r1
,
uint32
_t
r2
)
void
swap_row
(
size_t
r1
,
size
_t
r2
)
{
for
(
uint32
_t
c
=
0
;
c
<
dim_m
();
++
c
)
for
(
size
_t
c
=
0
;
c
<
dim_m
();
++
c
)
{
auto
v
=
operator
()(
r1
,
c
);
operator
()(
r1
,
c
)
=
operator
()(
r2
,
c
);
...
...
@@ -69,9 +69,9 @@ class matrix_expression
}
}
void
swap_col
(
uint32_t
c1
,
uint32
_t
c2
)
void
swap_col
(
size_t
c1
,
size
_t
c2
)
{
for
(
uint32
_t
r
=
0
;
r
<
dim_n
();
++
r
)
for
(
size
_t
r
=
0
;
r
<
dim_n
();
++
r
)
{
auto
&
a
=
operator
()(
r
,
c1
);
auto
&
b
=
operator
()(
r
,
c2
);
...
...
@@ -122,9 +122,9 @@ class matrix : public matrix_expression<matrix<F>>
,
m_n
(
m
.
dim_n
())
,
m_data
(
m_m
*
m_n
)
{
for
(
uint32
_t
i
=
0
;
i
<
m_m
;
++
i
)
for
(
size
_t
i
=
0
;
i
<
m_m
;
++
i
)
{
for
(
uint32
_t
j
=
0
;
j
<
m_n
;
++
j
)
for
(
size
_t
j
=
0
;
j
<
m_n
;
++
j
)
operator
()(
i
,
j
)
=
m
(
i
,
j
);
}
}
...
...
@@ -180,9 +180,9 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
matrix_fixed
(
const
M2
&
m
)
{
assert
(
M
==
m
.
dim_m
()
and
N
==
m
.
dim_n
());
for
(
uint32
_t
i
=
0
;
i
<
M
;
++
i
)
for
(
size
_t
i
=
0
;
i
<
M
;
++
i
)
{
for
(
uint32
_t
j
=
0
;
j
<
N
;
++
j
)
for
(
size
_t
j
=
0
;
j
<
N
;
++
j
)
operator
()(
i
,
j
)
=
m
(
i
,
j
);
}
}
...
...
@@ -244,7 +244,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
public
:
using
value_type
=
F
;
symmetric_matrix
(
uint32
_t
n
,
value_type
v
=
0
)
symmetric_matrix
(
size
_t
n
,
value_type
v
=
0
)
:
m_n
(
n
)
,
m_data
((
m_n
*
(
m_n
+
1
))
/
2
)
{
...
...
@@ -257,17 +257,17 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
symmetric_matrix
&
operator
=
(
symmetric_matrix
&&
m
)
=
default
;
symmetric_matrix
&
operator
=
(
const
symmetric_matrix
&
m
)
=
default
;
constexpr
uint32
_t
dim_m
()
const
{
return
m_n
;
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_n
;
}
constexpr
size
_t
dim_m
()
const
{
return
m_n
;
}
constexpr
size
_t
dim_n
()
const
{
return
m_n
;
}
constexpr
value_type
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
value_type
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
i
<
j
?
m_data
[(
j
*
(
j
+
1
))
/
2
+
i
]
:
m_data
[(
i
*
(
i
+
1
))
/
2
+
j
];
}
constexpr
value_type
&
operator
()(
uint32_t
i
,
uint32
_t
j
)
constexpr
value_type
&
operator
()(
size_t
i
,
size
_t
j
)
{
if
(
i
>
j
)
std
::
swap
(
i
,
j
);
...
...
@@ -276,7 +276,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
}
private
:
uint32
_t
m_n
;
size
_t
m_n
;
std
::
vector
<
value_type
>
m_data
;
};
...
...
@@ -298,17 +298,17 @@ class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F
symmetric_matrix_fixed
&
operator
=
(
symmetric_matrix_fixed
&&
m
)
=
default
;
symmetric_matrix_fixed
&
operator
=
(
const
symmetric_matrix_fixed
&
m
)
=
default
;
constexpr
uint32
_t
dim_m
()
const
{
return
M
;
}
constexpr
uint32
_t
dim_n
()
const
{
return
M
;
}
constexpr
size
_t
dim_m
()
const
{
return
M
;
}
constexpr
size
_t
dim_n
()
const
{
return
M
;
}
constexpr
value_type
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
value_type
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
i
<
j
?
m_data
[(
j
*
(
j
+
1
))
/
2
+
i
]
:
m_data
[(
i
*
(
i
+
1
))
/
2
+
j
];
}
constexpr
value_type
&
operator
()(
uint32_t
i
,
uint32
_t
j
)
constexpr
value_type
&
operator
()(
size_t
i
,
size
_t
j
)
{
if
(
i
>
j
)
std
::
swap
(
i
,
j
);
...
...
@@ -334,21 +334,21 @@ class identity_matrix : public matrix_expression<identity_matrix<F>>
public
:
using
value_type
=
F
;
identity_matrix
(
uint32
_t
n
)
identity_matrix
(
size
_t
n
)
:
m_n
(
n
)
{
}
constexpr
uint32
_t
dim_m
()
const
{
return
m_n
;
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_n
;
}
constexpr
size
_t
dim_m
()
const
{
return
m_n
;
}
constexpr
size
_t
dim_n
()
const
{
return
m_n
;
}
constexpr
value_type
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
value_type
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
i
==
j
?
1
:
0
;
return
static_cast
<
value_type
>
(
i
==
j
?
1
:
0
)
;
}
private
:
uint32
_t
m_n
;
size
_t
m_n
;
};
// --------------------------------------------------------------------
...
...
@@ -366,10 +366,10 @@ class matrix_subtraction : public matrix_expression<matrix_subtraction<M1, M2>>
assert
(
m_m1
.
dim_n
()
==
m_m2
.
dim_n
());
}
constexpr
uint32
_t
dim_m
()
const
{
return
m_m1
.
dim_m
();
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_m1
.
dim_n
();
}
constexpr
size
_t
dim_m
()
const
{
return
m_m1
.
dim_m
();
}
constexpr
size
_t
dim_n
()
const
{
return
m_m1
.
dim_n
();
}
constexpr
auto
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
auto
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
m_m1
(
i
,
j
)
-
m_m2
(
i
,
j
);
}
...
...
@@ -396,16 +396,16 @@ class matrix_matrix_multiplication : public matrix_expression<matrix_matrix_mult
assert
(
m1
.
dim_m
()
==
m2
.
dim_n
());
}
constexpr
uint32
_t
dim_m
()
const
{
return
m_m1
.
dim_m
();
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_m1
.
dim_n
();
}
constexpr
size
_t
dim_m
()
const
{
return
m_m1
.
dim_m
();
}
constexpr
size
_t
dim_n
()
const
{
return
m_m1
.
dim_n
();
}
constexpr
auto
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
auto
operator
()(
size_t
i
,
size
_t
j
)
const
{
using
value_type
=
decltype
(
m_m1
(
0
,
0
));
value_type
result
=
{};
for
(
uint32
_t
k
=
0
;
k
<
m_m1
.
dim_m
();
++
k
)
for
(
size
_t
k
=
0
;
k
<
m_m1
.
dim_m
();
++
k
)
result
+=
m_m1
(
i
,
k
)
*
m_m2
(
k
,
j
);
return
result
;
...
...
@@ -428,10 +428,10 @@ class matrix_scalar_multiplication : public matrix_expression<matrix_scalar_mult
{
}
constexpr
uint32
_t
dim_m
()
const
{
return
m_m
.
dim_m
();
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_m
.
dim_n
();
}
constexpr
size
_t
dim_m
()
const
{
return
m_m
.
dim_m
();
}
constexpr
size
_t
dim_n
()
const
{
return
m_m
.
dim_n
();
}
constexpr
auto
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
auto
operator
()(
size_t
i
,
size
_t
j
)
const
{
return
m_m
(
i
,
j
)
*
m_v
;
}
...
...
@@ -500,10 +500,10 @@ class matrix_cofactors : public matrix_expression<matrix_cofactors<M>>
{
}
constexpr
uint32
_t
dim_m
()
const
{
return
m_m
.
dim_m
();
}
constexpr
uint32
_t
dim_n
()
const
{
return
m_m
.
dim_n
();
}
constexpr
size
_t
dim_m
()
const
{
return
m_m
.
dim_m
();
}
constexpr
size
_t
dim_n
()
const
{
return
m_m
.
dim_n
();
}
constexpr
auto
operator
()(
uint32_t
i
,
uint32
_t
j
)
const
constexpr
auto
operator
()(
size_t
i
,
size
_t
j
)
const
{
const
size_t
ixs
[
4
][
3
]
=
{
{
1
,
2
,
3
},
...
...
include/cif++/symmetry.hpp
View file @
1f314a5e
...
...
@@ -184,7 +184,7 @@ class datablock;
class
cell
;
class
spacegroup
;
class
rtop
;
class
sym_op
;
struct
sym_op
;
/// @brief A class that encapsulates the symmetry operations as used in PDB files, i.e. a rotational number and a translation vector
...
...
src/category.cpp
View file @
1f314a5e
...
...
@@ -1976,13 +1976,13 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if
(
s
.
empty
())
s
=
"?"
;
size_t
l
=
s
.
length
();
size_t
l
2
=
s
.
length
();
if
(
not
sac_parser
::
is_unquoted_string
(
s
))
l
+=
2
;
l
2
+=
2
;
if
(
width
<
l
)
width
=
l
;
if
(
width
<
l
2
)
width
=
l
2
;
}
for
(
uint16_t
cix
:
order
)
...
...
src/point.cpp
View file @
1f314a5e
...
...
@@ -61,7 +61,7 @@ quaternion_type<T> normalize(quaternion_type<T> q)
quaternion
construct_from_angle_axis
(
float
angle
,
point
axis
)
{
angle
=
(
angle
*
kPI
/
180
)
/
2
;
angle
=
static_cast
<
float
>
((
angle
*
kPI
/
180
)
/
2
)
;
auto
s
=
std
::
sin
(
angle
);
auto
c
=
std
::
cos
(
angle
);
...
...
@@ -119,7 +119,7 @@ point center_points(std::vector<point> &Points)
}
quaternion
construct_for_dihedral_angle
(
point
p1
,
point
p2
,
point
p3
,
point
p4
,
float
angle
,
float
esd
)
float
angle
,
float
/*esd*/
)
{
p1
-=
p3
;
p2
-=
p3
;
...
...
src/symmetry.cpp
View file @
1f314a5e
...
...
@@ -70,12 +70,12 @@ void cell::init()
m_orthogonal
=
identity_matrix
(
3
);
m_orthogonal
(
0
,
0
)
=
m_a
;
m_orthogonal
(
0
,
1
)
=
m_b
*
std
::
cos
(
gamma
);
m_orthogonal
(
0
,
2
)
=
m_c
*
std
::
cos
(
beta
);
m_orthogonal
(
1
,
1
)
=
m_b
*
std
::
sin
(
gamma
);
m_orthogonal
(
1
,
2
)
=
-
m_c
*
std
::
sin
(
beta
)
*
std
::
cos
(
alpha_star
);
m_orthogonal
(
2
,
2
)
=
m_c
*
std
::
sin
(
beta
)
*
std
::
sin
(
alpha_star
);
m_orthogonal
(
0
,
0
)
=
static_cast
<
float
>
(
m_a
)
;
m_orthogonal
(
0
,
1
)
=
static_cast
<
float
>
(
m_b
*
std
::
cos
(
gamma
)
);
m_orthogonal
(
0
,
2
)
=
static_cast
<
float
>
(
m_c
*
std
::
cos
(
beta
)
);
m_orthogonal
(
1
,
1
)
=
static_cast
<
float
>
(
m_b
*
std
::
sin
(
gamma
)
);
m_orthogonal
(
1
,
2
)
=
static_cast
<
float
>
(
-
m_c
*
std
::
sin
(
beta
)
*
std
::
cos
(
alpha_star
)
);
m_orthogonal
(
2
,
2
)
=
static_cast
<
float
>
(
m_c
*
std
::
sin
(
beta
)
*
std
::
sin
(
alpha_star
)
);
m_fractional
=
inverse
(
m_orthogonal
);
}
...
...
@@ -90,7 +90,7 @@ sym_op::sym_op(std::string_view s)
int
rnri
=
256
;
// default to unexisting number
auto
r
=
std
::
from_chars
(
b
,
e
,
rnri
);
m_nr
=
rnri
;
m_nr
=
static_cast
<
uint8_t
>
(
rnri
)
;
m_ta
=
r
.
ptr
[
1
]
-
'0'
;
m_tb
=
r
.
ptr
[
2
]
-
'0'
;
m_tc
=
r
.
ptr
[
3
]
-
'0'
;
...
...
@@ -121,21 +121,21 @@ transformation::transformation(const symop_data &data)
{
const
auto
&
d
=
data
.
data
();
m_rotation
(
0
,
0
)
=
d
[
0
]
;
m_rotation
(
0
,
1
)
=
d
[
1
]
;
m_rotation
(
0
,
2
)
=
d
[
2
]
;
m_rotation
(
1
,
0
)
=
d
[
3
]
;
m_rotation
(
1
,
1
)
=
d
[
4
]
;
m_rotation
(
1
,
2
)
=
d
[
5
]
;
m_rotation
(
2
,
0
)
=
d
[
6
]
;
m_rotation
(
2
,
1
)
=
d
[
7
]
;
m_rotation
(
2
,
2
)
=
d
[
8
]
;
m_rotation
(
0
,
0
)
=
static_cast
<
float
>
(
d
[
0
])
;
m_rotation
(
0
,
1
)
=
static_cast
<
float
>
(
d
[
1
])
;
m_rotation
(
0
,
2
)
=
static_cast
<
float
>
(
d
[
2
])
;
m_rotation
(
1
,
0
)
=
static_cast
<
float
>
(
d
[
3
])
;
m_rotation
(
1
,
1
)
=
static_cast
<
float
>
(
d
[
4
])
;
m_rotation
(
1
,
2
)
=
static_cast
<
float
>
(
d
[
5
])
;
m_rotation
(
2
,
0
)
=
static_cast
<
float
>
(
d
[
6
])
;
m_rotation
(
2
,
1
)
=
static_cast
<
float
>
(
d
[
7
])
;
m_rotation
(
2
,
2
)
=
static_cast
<
float
>
(
d
[
8
])
;
try_create_quaternion
();
m_translation
.
m_x
=
d
[
9
]
==
0
?
0
:
1.0
*
d
[
9
]
/
d
[
10
]
;
m_translation
.
m_y
=
d
[
11
]
==
0
?
0
:
1.0
*
d
[
11
]
/
d
[
12
]
;
m_translation
.
m_z
=
d
[
13
]
==
0
?
0
:
1.0
*
d
[
13
]
/
d
[
14
]
;
m_translation
.
m_x
=
static_cast
<
float
>
(
d
[
9
]
==
0
?
0
:
1.0
*
d
[
9
]
/
d
[
10
])
;
m_translation
.
m_y
=
static_cast
<
float
>
(
d
[
11
]
==
0
?
0
:
1.0
*
d
[
11
]
/
d
[
12
])
;
m_translation
.
m_z
=
static_cast
<
float
>
(
d
[
13
]
==
0
?
0
:
1.0
*
d
[
13
]
/
d
[
14
])
;
}
transformation
::
transformation
(
const
matrix3x3
<
float
>
&
r
,
const
cif
::
point
&
t
)
...
...
@@ -461,7 +461,7 @@ std::tuple<float,point,sym_op> crystal::closest_symmetry_copy(point a, point b)
for
(
size_t
i
=
0
;
i
<
m_spacegroup
.
size
();
++
i
)
{
sym_op
s
(
i
+
1
);
sym_op
s
(
static_cast
<
uint8_t
>
(
i
+
1
)
);
auto
&
t
=
m_spacegroup
[
i
];
auto
fsb
=
t
(
fb
);
...
...
src/text.cpp
View file @
1f314a5e
...
...
@@ -239,7 +239,7 @@ std::string cif_id_for_number(int number)
do
{
int
r
=
number
%
26
;
result
+=
'A'
+
r
;
result
+=
static_cast
<
char
>
(
'A'
+
r
)
;
number
=
(
number
-
r
)
/
26
-
1
;
}
...
...
src/utilities.cpp
View file @
1f314a5e
...
...
@@ -204,7 +204,7 @@ void progress_bar_impl::run()
std
::
lock_guard
lock
(
m_mutex
);
if
(
not
printedAny
and
isatty
(
STDOUT_FILENO
))
std
::
cout
<<
"\
e
[?25l"
;
std
::
cout
<<
"
\
x1b
[?25l"
;
print_progress
();
...
...
@@ -220,7 +220,7 @@ void progress_bar_impl::run()
{
print_done
();
if
(
isatty
(
STDOUT_FILENO
))
std
::
cout
<<
"\
e
[?25h"
;
std
::
cout
<<
"
\
x1b
[?25h"
;
}
}
...
...
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