OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
RectMatrix.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45/**
46 * @file RectMatrix.hpp
47 * @author Teng Lin
48 * @date 10/11/2004
49 * @version 1.0
50 */
51
52#ifndef MATH_RECTMATRIX_HPP
53#define MATH_RECTMATRIX_HPP
54
55#include <cmath>
56
57#include "Vector.hpp"
58
59namespace OpenMD {
60
61 /**
62 * @class RectMatrix RectMatrix.hpp "math/RectMatrix.hpp"
63 * @brief rectangular matrix class
64 */
65 template<typename Real, unsigned int Row, unsigned int Col>
66 class RectMatrix {
67 public:
68 using ElemType = Real;
69 using ElemPoinerType = Real*;
70
71 /** default constructor */
73 for (unsigned int i = 0; i < Row; i++)
74 for (unsigned int j = 0; j < Col; j++)
75 this->data_[i][j] = 0.0;
76 }
77
78 /** Constructs and initializes every element of this matrix to a scalar */
79 RectMatrix(Real s) {
80 for (unsigned int i = 0; i < Row; i++)
81 for (unsigned int j = 0; j < Col; j++)
82 this->data_[i][j] = s;
83 }
84
85 RectMatrix(Real* array) {
86 for (unsigned int i = 0; i < Row; i++)
87 for (unsigned int j = 0; j < Col; j++)
88 this->data_[i][j] = array[i * Row + j];
89 }
90
91 /** copy constructor */
92 RectMatrix(const RectMatrix<Real, Row, Col>& m) { *this = m; }
93
94 /** destructor*/
96
97 /** copy assignment operator */
99 if (this == &m) return *this;
100
101 for (unsigned int i = 0; i < Row; i++)
102 for (unsigned int j = 0; j < Col; j++)
103 this->data_[i][j] = m.data_[i][j];
104 return *this;
105 }
106
107 /**
108 * Return the reference of a single element of this matrix.
109 * @return the reference of a single element of this matrix
110 * @param i row index
111 * @param j Column index
112 */
113 Real& operator()(unsigned int i, unsigned int j) {
114 // assert( i < Row && j < Col);
115 return this->data_[i][j];
116 }
117
118 /**
119 * Return the value of a single element of this matrix.
120 * @return the value of a single element of this matrix
121 * @param i row index
122 * @param j Column index
123 */
124 Real operator()(unsigned int i, unsigned int j) const {
125 return this->data_[i][j];
126 }
127
128 /**
129 * Copy the internal data to an array
130 * @param array the pointer of destination array
131 */
132 void getArray(Real* array) {
133 for (unsigned int i = 0; i < Row; i++) {
134 for (unsigned int j = 0; j < Col; j++) {
135 array[i * Row + j] = this->data_[i][j];
136 }
137 }
138 }
139
140 /** Returns the pointer of internal array */
141 Real* getArrayPointer() { return &this->data_[0][0]; }
142
143 /**
144 * Returns a row of this matrix as a vector.
145 * @return a row of this matrix as a vector
146 * @param row the row index
147 */
148 Vector<Real, Row> getRow(unsigned int row) {
150
151 for (unsigned int i = 0; i < Col; i++)
152 v[i] = this->data_[row][i];
153
154 return v;
155 }
156
157 /**
158 * Sets a row of this matrix
159 * @param row the row index
160 * @param v the vector to be set
161 */
162 void setRow(unsigned int row, const Vector<Real, Row>& v) {
163 for (unsigned int i = 0; i < Col; i++)
164 this->data_[row][i] = v[i];
165 }
166
167 /**
168 * Returns a column of this matrix as a vector.
169 * @return a column of this matrix as a vector
170 * @param col the column index
171 */
172 Vector<Real, Col> getColumn(unsigned int col) {
174
175 for (unsigned int j = 0; j < Row; j++)
176 v[j] = this->data_[j][col];
177
178 return v;
179 }
180
181 /**
182 * Sets a column of this matrix
183 * @param col the column index
184 * @param v the vector to be set
185 */
186 void setColumn(unsigned int col, const Vector<Real, Col>& v) {
187 for (unsigned int j = 0; j < Row; j++)
188 this->data_[j][col] = v[j];
189 }
190
191 /**
192 * swap two rows of this matrix
193 * @param i the first row
194 * @param j the second row
195 */
196 void swapRow(unsigned int i, unsigned int j) {
197 assert(i < Row && j < Row);
198
199 for (unsigned int k = 0; k < Col; k++)
200 std::swap(this->data_[i][k], this->data_[j][k]);
201 }
202
203 /**
204 * swap two Columns of this matrix
205 * @param i the first Column
206 * @param j the second Column
207 */
208 void swapColumn(unsigned int i, unsigned int j) {
209 assert(i < Col && j < Col);
210
211 for (unsigned int k = 0; k < Row; k++)
212 std::swap(this->data_[k][i], this->data_[k][j]);
213 }
214
215 /**
216 * Tests if this matrix is identical to matrix m
217 * @return true if this matrix is equal to the matrix m, return false
218 * otherwise
219 * @param m matrix to be compared
220 *
221 * @todo replace operator == by template function equal
222 */
224 for (unsigned int i = 0; i < Row; i++)
225 for (unsigned int j = 0; j < Col; j++)
226 if (!equal(this->data_[i][j], m.data_[i][j])) return false;
227
228 return true;
229 }
230
231 /**
232 * Tests if this matrix is not equal to matrix m
233 * @return true if this matrix is not equal to the matrix m, return false
234 * otherwise
235 * @param m matrix to be compared
236 */
238 return !(*this == m);
239 }
240
241 /** Negates the value of this matrix in place. */
242 inline void negate() {
243 for (unsigned int i = 0; i < Row; i++)
244 for (unsigned int j = 0; j < Col; j++)
245 this->data_[i][j] = -this->data_[i][j];
246 }
247
248 /**
249 * Sets the value of this matrix to the negation of matrix m.
250 * @param m the source matrix
251 */
252 inline void negate(const RectMatrix<Real, Row, Col>& m) {
253 for (unsigned int i = 0; i < Row; i++)
254 for (unsigned int j = 0; j < Col; j++)
255 this->data_[i][j] = -m.data_[i][j];
256 }
257
258 /**
259 * Sets the value of this matrix to the sum of itself and m (*this += m).
260 * @param m the other matrix
261 */
262 inline void add(const RectMatrix<Real, Row, Col>& m) {
263 for (unsigned int i = 0; i < Row; i++)
264 for (unsigned int j = 0; j < Col; j++)
265 this->data_[i][j] += m.data_[i][j];
266 }
267
268 /**
269 * Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).
270 * @param m1 the first matrix
271 * @param m2 the second matrix
272 */
273 inline void add(const RectMatrix<Real, Row, Col>& m1,
274 const RectMatrix<Real, Row, Col>& m2) {
275 for (unsigned int i = 0; i < Row; i++)
276 for (unsigned int j = 0; j < Col; j++)
277 this->data_[i][j] = m1.data_[i][j] + m2.data_[i][j];
278 }
279
280 /**
281 * Sets the value of this matrix to the difference of itself and m (*this
282 * -= m).
283 * @param m the other matrix
284 */
285 inline void sub(const RectMatrix<Real, Row, Col>& m) {
286 for (unsigned int i = 0; i < Row; i++)
287 for (unsigned int j = 0; j < Col; j++)
288 this->data_[i][j] -= m.data_[i][j];
289 }
290
291 /**
292 * Sets the value of this matrix to the difference of matrix m1 and m2
293 * (*this = m1 - m2).
294 * @param m1 the first matrix
295 * @param m2 the second matrix
296 */
297 inline void sub(const RectMatrix<Real, Row, Col>& m1,
298 const RectMatrix<Real, Row, Col>& m2) {
299 for (unsigned int i = 0; i < Row; i++)
300 for (unsigned int j = 0; j < Col; j++)
301 this->data_[i][j] = m1.data_[i][j] - m2.data_[i][j];
302 }
303
304 /**
305 * Sets the value of this matrix to the scalar multiplication of itself
306 * (*this *= s).
307 * @param s the scalar value
308 */
309 inline void mul(Real s) {
310 for (unsigned int i = 0; i < Row; i++)
311 for (unsigned int j = 0; j < Col; j++)
312 this->data_[i][j] *= s;
313 }
314
315 /**
316 * Sets the value of this matrix to the scalar multiplication of matrix m
317 * (*this = s * m).
318 * @param s the scalar value
319 * @param m the matrix
320 */
321 inline void mul(Real s, const RectMatrix<Real, Row, Col>& m) {
322 for (unsigned int i = 0; i < Row; i++)
323 for (unsigned int j = 0; j < Col; j++)
324 this->data_[i][j] = s * m.data_[i][j];
325 }
326
327 /**
328 * Sets the value of this matrix to the scalar division of itself (*this /=
329 * s ).
330 * @param s the scalar value
331 */
332 inline void div(Real s) {
333 for (unsigned int i = 0; i < Row; i++)
334 for (unsigned int j = 0; j < Col; j++)
335 this->data_[i][j] /= s;
336 }
337
338 /**
339 * Sets the value of this matrix to the scalar division of matrix m (*this
340 * = m /s).
341 * @param s the scalar value
342 * @param m the matrix
343 */
344 inline void div(Real s, const RectMatrix<Real, Row, Col>& m) {
345 for (unsigned int i = 0; i < Row; i++)
346 for (unsigned int j = 0; j < Col; j++)
347 this->data_[i][j] = m.data_[i][j] / s;
348 }
349
350 /**
351 * Multiples a scalar into every element of this matrix.
352 * @param s the scalar value
353 */
355 this->mul(s);
356 return *this;
357 }
358
359 /**
360 * Divides every element of this matrix by a scalar.
361 * @param s the scalar value
362 */
364 this->div(s);
365 return *this;
366 }
367
368 /**
369 * Sets the value of this matrix to the sum of the other matrix and itself
370 * (*this += m).
371 * @param m the other matrix
372 */
375 add(m);
376 return *this;
377 }
378
379 /**
380 * Sets the value of this matrix to the differerence of itself and the other
381 * matrix (*this -= m)
382 * @param m the other matrix
383 */
386 sub(m);
387 return *this;
388 }
389
390 /** Return the transpose of this matrix */
393
394 for (unsigned int i = 0; i < Row; i++)
395 for (unsigned int j = 0; j < Col; j++)
396 result(j, i) = this->data_[i][j];
397
398 return result;
399 }
400
401 template<class MatrixType>
402 void setSubMatrix(unsigned int beginRow, unsigned int beginCol,
403 const MatrixType& m) {
404 assert(beginRow + m.getNRow() - 1 <= getNRow());
405 assert(beginCol + m.getNCol() - 1 <= getNCol());
406
407 for (unsigned int i = 0; i < m.getNRow(); ++i)
408 for (unsigned int j = 0; j < m.getNCol(); ++j)
409 this->data_[beginRow + i][beginCol + j] = m(i, j);
410 }
411
412 template<class MatrixType>
413 void getSubMatrix(unsigned int beginRow, unsigned int beginCol,
414 MatrixType& m) {
415 assert(beginRow + m.getNRow() - 1 <= getNRow());
416 assert(beginCol + m.getNCol() - 1 <= getNCol());
417
418 for (unsigned int i = 0; i < m.getNRow(); ++i)
419 for (unsigned int j = 0; j < m.getNCol(); ++j)
420 m(i, j) = this->data_[beginRow + i][beginCol + j];
421 }
422
423 unsigned int getNRow() const { return Row; }
424 unsigned int getNCol() const { return Col; }
425
426 Real frobeniusNorm() {
427 Real norm(0.0);
428 for (unsigned int i = 0; i < Row; i++) {
429 for (unsigned int j = 0; j < Col; j++) {
430 norm += pow(abs(this->data_[i][j]), 2);
431 }
432 }
433 return sqrt(norm);
434 }
435
436 protected:
437 Real data_[Row][Col];
438 };
439
440 /** Negate the value of every element of this matrix. */
441 template<typename Real, unsigned int Row, unsigned int Col>
445
446 result.negate();
447
448 return result;
449 }
450
451 /**
452 * Return the sum of two matrixes (m1 + m2).
453 * @return the sum of two matrixes
454 * @param m1 the first matrix
455 * @param m2 the second matrix
456 */
457 template<typename Real, unsigned int Row, unsigned int Col>
460 const RectMatrix<Real, Row, Col>& m2) {
462
463 result.add(m1, m2);
464
465 return result;
466 }
467
468 /**
469 * Return the difference of two matrixes (m1 - m2).
470 * @return the sum of two matrixes
471 * @param m1 the first matrix
472 * @param m2 the second matrix
473 */
474 template<typename Real, unsigned int Row, unsigned int Col>
477 const RectMatrix<Real, Row, Col>& m2) {
479
480 result.sub(m1, m2);
481
482 return result;
483 }
484
485 /**
486 * Return the multiplication of scalra and matrix (m * s).
487 * @return the multiplication of a scalra and a matrix
488 * @param m the matrix
489 * @param s the scalar
490 */
491 template<typename Real, unsigned int Row, unsigned int Col>
493 const RectMatrix<Real, Row, Col>& m, Real s) {
495
496 result.mul(s, m);
497
498 return result;
499 }
500
501 /**
502 * Return the multiplication of a scalra and a matrix (s * m).
503 * @return the multiplication of a scalra and a matrix
504 * @param s the scalar
505 * @param m the matrix
506 */
507 template<typename Real, unsigned int Row, unsigned int Col>
509 Real s, const RectMatrix<Real, Row, Col>& m) {
511
512 result.mul(s, m);
513
514 return result;
515 }
516
517 /**
518 * Return the multiplication of two matrixes (m1 * m2).
519 * @return the multiplication of two matrixes
520 * @param m1 the first matrix
521 * @param m2 the second matrix
522 */
523 template<typename Real, unsigned int Row, unsigned int Col,
524 unsigned int SameDim>
529
530 for (unsigned int i = 0; i < Row; i++)
531 for (unsigned int j = 0; j < Col; j++)
532 for (unsigned int k = 0; k < SameDim; k++)
533 result(i, j) += m1(i, k) * m2(k, j);
534
535 return result;
536 }
537
538 /**
539 * Returns the multiplication of a matrix and a vector (m * v).
540 * @return the multiplication of a matrix and a vector
541 * @param m the matrix
542 * @param v the vector
543 */
544 template<typename Real, unsigned int Row, unsigned int Col>
546 const Vector<Real, Col>& v) {
547 Vector<Real, Row> result;
548
549 for (unsigned int i = 0; i < Row; i++)
550 for (unsigned int j = 0; j < Col; j++)
551 result[i] += m(i, j) * v[j];
552
553 return result;
554 }
555
556 /**
557 * Returns the multiplication of a vector transpose and a matrix (v^T * m).
558 * @return the multiplication of a vector transpose and a matrix
559 * @param v the vector
560 * @param m the matrix
561 */
562 template<typename Real, unsigned int Row, unsigned int Col>
565 Vector<Real, Row> result;
566
567 for (unsigned int i = 0; i < Col; i++)
568 for (unsigned int j = 0; j < Row; j++)
569 result[i] += v[j] * m(j, i);
570
571 return result;
572 }
573
574 /**
575 * Return the scalar division of matrix (m / s).
576 * @return the scalar division of matrix
577 * @param m the matrix
578 * @param s the scalar
579 */
580 template<typename Real, unsigned int Row, unsigned int Col>
582 const RectMatrix<Real, Row, Col>& m, Real s) {
584
585 result.div(s, m);
586
587 return result;
588 }
589
590 /**
591 * Returns the tensor contraction (double dot product) of two rank 2
592 * tensors (or Matrices)
593 *
594 * \f[ \mathbf{A} \colon \! \mathbf{B} = \sum_\alpha \sum_\beta
595 * \mathbf{A}_{\alpha \beta} B_{\alpha \beta} \f]
596 *
597 * @param t1 first tensor
598 * @param t2 second tensor
599 * @return the tensor contraction (double dot product) of t1 and t2
600 */
601 template<typename Real, unsigned int Row, unsigned int Col>
603 const RectMatrix<Real, Row, Col>& t2) {
604 Real tmp;
605 tmp = 0;
606
607 for (unsigned int i = 0; i < Row; i++)
608 for (unsigned int j = 0; j < Col; j++)
609 tmp += t1(i, j) * t2(i, j);
610
611 return tmp;
612 }
613
614 /**
615 * Returns the vector (cross) product of two matrices. This
616 * operation is defined in:
617 *
618 * W. Smith, "Point Multipoles in the Ewald Summation (Revisited),"
619 * CCP5 Newsletter No 46., pp. 18-30.
620 *
621 * Equation 21 defines:
622 * \f[
623 * V_alpha = \sum_\beta \left[ A_{\alpha+1,\beta} * B_{\alpha+2,\beta}
624 -A_{\alpha+2,\beta} * B_{\alpha+2,\beta} \right]
625 * \f]
626
627 * where \f[\alpha+1\f] and \f[\alpha+2\f] are regarded as cyclic
628 * permuations of the matrix indices (i.e. for a 3x3 matrix, when
629 * \f[\alpha = 2\f], \f[\alpha + 1 = 3 \f], and \f[\alpha + 2 = 1 \f] ).
630 *
631 * @param t1 first matrix
632 * @param t2 second matrix
633 * @return the cross product (vector product) of t1 and t2
634 */
635 template<typename Real, unsigned int Row, unsigned int Col>
637 const RectMatrix<Real, Row, Col>& t2) {
638 Vector<Real, Row> result;
639 unsigned int i1;
640 unsigned int i2;
641
642 for (unsigned int i = 0; i < Row; i++) {
643 i1 = (i + 1) % Row;
644 i2 = (i + 2) % Row;
645 for (unsigned int j = 0; j < Col; j++) {
646 result[i] += t1(i1, j) * t2(i2, j) - t1(i2, j) * t2(i1, j);
647 }
648 }
649 return result;
650 }
651
652 /**
653 * Write to an output stream
654 */
655 template<typename Real, unsigned int Row, unsigned int Col>
656 std::ostream& operator<<(std::ostream& o,
658 for (unsigned int i = 0; i < Row; i++) {
659 o << "(";
660 for (unsigned int j = 0; j < Col; j++) {
661 o << m(i, j);
662 if (j != Col - 1) o << "\t";
663 }
664 o << ")" << std::endl;
665 }
666 return o;
667 }
668} // namespace OpenMD
669
670#endif // MATH_RECTMATRIX_HPP
rectangular matrix class
RectMatrix< Real, Col, Row > transpose() const
Return the transpose of this matrix.
void negate(const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the negation of matrix m.
RectMatrix(const RectMatrix< Real, Row, Col > &m)
copy constructor
void sub(const RectMatrix< Real, Row, Col > &m1, const RectMatrix< Real, Row, Col > &m2)
Sets the value of this matrix to the difference of matrix m1 and m2 (*this = m1 - m2).
RectMatrix< Real, Row, Col > & operator-=(const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the differerence of itself and the other matrix (*this -= m)
void sub(const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the difference of itself and m (*this -= m).
void add(const RectMatrix< Real, Row, Col > &m1, const RectMatrix< Real, Row, Col > &m2)
Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).
~RectMatrix()
destructor
Vector< Real, Row > getRow(unsigned int row)
Returns a row of this matrix as a vector.
void setRow(unsigned int row, const Vector< Real, Row > &v)
Sets a row of this matrix.
void mul(Real s, const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the scalar multiplication of matrix m (*this = s * m).
void div(Real s)
Sets the value of this matrix to the scalar division of itself (*this /= s ).
void setColumn(unsigned int col, const Vector< Real, Col > &v)
Sets a column of this matrix.
RectMatrix< Real, Row, Col > & operator/=(const Real s)
Divides every element of this matrix by a scalar.
RectMatrix< Real, Row, Col > & operator+=(const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the sum of the other matrix and itself (*this += m).
void swapColumn(unsigned int i, unsigned int j)
swap two Columns of this matrix
Vector< Real, Col > getColumn(unsigned int col)
Returns a column of this matrix as a vector.
RectMatrix()
default constructor
bool operator!=(const RectMatrix< Real, Row, Col > &m)
Tests if this matrix is not equal to matrix m.
void div(Real s, const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the scalar division of matrix m (*this = m /s).
void getArray(Real *array)
Copy the internal data to an array.
bool operator==(const RectMatrix< Real, Row, Col > &m)
Tests if this matrix is identical to matrix m.
void mul(Real s)
Sets the value of this matrix to the scalar multiplication of itself (*this *= s).
Real * getArrayPointer()
Returns the pointer of internal array.
Real & operator()(unsigned int i, unsigned int j)
Return the reference of a single element of this matrix.
void negate()
Negates the value of this matrix in place.
void swapRow(unsigned int i, unsigned int j)
swap two rows of this matrix
RectMatrix< Real, Row, Col > & operator*=(const Real s)
Multiples a scalar into every element of this matrix.
void add(const RectMatrix< Real, Row, Col > &m)
Sets the value of this matrix to the sum of itself and m (*this += m).
RectMatrix(Real s)
Constructs and initializes every element of this matrix to a scalar.
RectMatrix< Real, Row, Col > & operator=(const RectMatrix< Real, Row, Col > &m)
copy assignment operator
Real operator()(unsigned int i, unsigned int j) const
Return the value of a single element of this matrix.
Fix length vector class.
Definition Vector.hpp:78
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Real doubleDot(const RectMatrix< Real, Row, Col > &t1, const RectMatrix< Real, Row, Col > &t2)
Returns the tensor contraction (double dot product) of two rank 2 tensors (or Matrices)
DynamicRectMatrix< Real > operator-(const DynamicRectMatrix< Real > &m)
Negate the value of every element of this matrix.
bool equal(const Polynomial< Real > &p1, const Polynomial< Real > &p2)
Tests if two polynomial have the same exponents.
DynamicRectMatrix< Real > operator*(const DynamicRectMatrix< Real > &m, Real s)
Return the multiplication of scalar and matrix (m * s).
Vector< Real, Row > mCross(const RectMatrix< Real, Row, Col > &t1, const RectMatrix< Real, Row, Col > &t2)
Returns the vector (cross) product of two matrices.
DynamicRectMatrix< Real > operator/(const DynamicRectMatrix< Real > &m, Real s)
Return the scalar division of matrix (m / s).