29 #ifndef CDPL_MATH_VECTORARRAYFUNCTIONS_HPP
30 #define CDPL_MATH_VECTORARRAYFUNCTIONS_HPP
53 template <
typename T, std::
size_t Dim,
typename T1>
60 typedef typename VecType::Pointer VecDataPointer;
61 typedef typename MtxType::ConstArrayPointer MtxDataPointer;
64 MtxDataPointer xform_data = xform.
getData();
66 for (Iterator it = va.getElementsBegin(), end = va.getElementsEnd(); it != end; ++it) {
67 VecDataPointer
vec = it->getData();
69 for (std::size_t i = 0; i < Dim; i++) {
72 for (std::size_t j = 0; j < Dim; j++)
73 tmp[i] +=
vec[j] * xform_data[i][j];
76 for (std::size_t i = 0; i < Dim; i++)
90 template <
typename T, std::
size_t Dim,
typename T1>
97 typedef typename VecType::Pointer VecDataPointer;
98 typedef typename MtxType::ConstArrayPointer MtxDataPointer;
101 MtxDataPointer xform_data = xform.
getData();
103 for (Iterator it = va.getElementsBegin(), end = va.getElementsEnd(); it != end; ++it) {
104 VecDataPointer
vec = it->getData();
106 for (std::size_t i = 0; i < Dim; i++) {
109 for (std::size_t j = 0; j < Dim; j++)
110 tmp[i] +=
vec[j] * xform_data[i][j];
112 tmp[i] += xform_data[i][Dim];
115 for (std::size_t i = 0; i < Dim; i++)
129 template <
typename T, std::
size_t Dim,
typename T1>
139 for (Iterator it = va.getElementsBegin(), end = va.getElementsEnd(); it != end; ++it)
158 template <
typename T, std::
size_t Dim>
164 ArraySizeType num_elem = std::min(va1.getSize(), va2.getSize());
170 typedef typename VecType::ConstPointer VecDataPointer;
174 for (Iterator it1 = va1.getElementsBegin(), it2 = va2.getElementsBegin(), end = it1 + num_elem; it1 != end; ++it1, ++it2) {
175 VecDataPointer vec1 = it1->getData();
176 VecDataPointer vec2 = it2->getData();
178 for (std::size_t i = 0; i < Dim; i++) {
179 T diff = vec1[i] - vec2[i];
185 return std::sqrt(sd / num_elem);
202 template <
typename T, std::
size_t Dim,
typename T1>
210 ArraySizeType num_elem = std::min(va1.getSize(), va2.getSize());
216 typedef typename VecType::ConstPointer VecDataPointer;
217 typedef typename MtxType::ConstArrayPointer MtxDataPointer;
220 MtxDataPointer xform_data = va1_xform.
getData();
222 for (Iterator it1 = va1.getElementsBegin(), it2 = va2.getElementsBegin(), end = it1 + num_elem; it1 != end; ++it1, ++it2) {
223 VecDataPointer vec1 = it1->getData();
224 VecDataPointer vec2 = it2->getData();
226 for (std::size_t i = 0; i < Dim; i++) {
229 for (std::size_t j = 0; j < Dim; j++)
230 tmp += vec1[j] * xform_data[i][j];
232 tmp += xform_data[i][Dim] - vec2[i];
237 return std::sqrt(sd / num_elem);
Definition of matrix data types.
Definition of class CDPL::Math::VectorArray.
Fixed-size dense matrix of dimensions M N backed by a 2D C-array (no dynamic allocation).
Definition: Matrix.hpp:1987
ArrayPointer getData()
Returns a mutable pointer-to-row to the contiguous 2D element array.
Definition: Matrix.hpp:2154
Fixed-size vector of dimension N backed by a C-array (no dynamic allocation).
Definition: Vector.hpp:1876
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v.
Definition: Vector.hpp:2294
CVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:2229
SizeType getSize() const
Returns the fixed element count N.
Definition: Vector.hpp:2016
Array data type for the ordered storage of vector objects.
Definition: VectorArray.hpp:49
StorageType::const_iterator ConstElementIterator
A constant random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:125
StorageType::iterator ElementIterator
A mutable random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:137
std::size_t SizeType
The type of objects stored by the array.
Definition: Array.hpp:110
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
bool calcCentroid(const VectorArray< CVector< T, Dim > > &va, CVector< T1, Dim > &ctr)
Calculates the centroid of the array elements.
Definition: VectorArrayFunctions.hpp:130
QuaternionVectorAdapter< E > vec(QuaternionExpression< E > &e)
Creates a mutable Math::QuaternionVectorAdapter view of the quaternion expression e.
Definition: QuaternionAdapter.hpp:372
T calcRMSD(const VectorArray< CVector< T, Dim > > &va1, const VectorArray< CVector< T, Dim > > &va2)
Calculates the root-mean-square distance between the corresponding elements of va1 and va2.
Definition: VectorArrayFunctions.hpp:159
void transform(VectorArray< CVector< T, Dim > > &va, const CMatrix< T1, Dim, Dim > &xform)
Transforms each -dimensional vector in the array with the -dimensional square matrix xform.
Definition: VectorArrayFunctions.hpp:54
The namespace of the Chemical Data Processing Library.