OpenMD 3.2
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 following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48/**
49 * @file RectMatrix.hpp
50 * @author Teng Lin
51 * @date 10/11/2004
52 * @version 1.0
53 */
54
55#ifndef MATH_RECTMATRIX_HPP
56#define MATH_RECTMATRIX_HPP
57
58#include <cmath>
59
60#include "Vector.hpp"
61
62namespace OpenMD {
63
64 /**
65 * @class RectMatrix RectMatrix.hpp "math/RectMatrix.hpp"
66 * @brief rectangular matrix class
67 */
68 template<typename Real, unsigned int Row, unsigned int Col>
69 class RectMatrix {
70 public:
71 using ElemType = Real;
72 using ElemPoinerType = Real*;
73
74 /** default constructor */
76 for (unsigned int i = 0; i < Row; i++)
77 for (unsigned int j = 0; j < Col; j++)
78 this->data_[i][j] = 0.0;
79 }
80
81 /** Constructs and initializes every element of this matrix to a scalar */
82 RectMatrix(Real s) {
83 for (unsigned int i = 0; i < Row; i++)
84 for (unsigned int j = 0; j < Col; j++)
85 this->data_[i][j] = s;
86 }
87
88 RectMatrix(Real* array) {
89 for (unsigned int i = 0; i < Row; i++)
90 for (unsigned int j = 0; j < Col; j++)
91 this->data_[i][j] = array[i * Row + j];
92 }
93
94 /** copy constructor */
95 RectMatrix(const RectMatrix<Real, Row, Col>& m) { *this = m; }
96
97 /** destructor*/
99
100 /** copy assignment operator */
102 if (this == &m) return *this;
103
104 for (unsigned int i = 0; i < Row; i++)
105 for (unsigned int j = 0; j < Col; j++)
106 this->data_[i][j] = m.data_[i][j];
107 return *this;
108 }
109
110 /**
111 * Return the reference of a single element of this matrix.
112 * @return the reference of a single element of this matrix
113 * @param i row index
114 * @param j Column index
115 */
116 Real& operator()(unsigned int i, unsigned int j) {
117 // assert( i < Row && j < Col);
118 return this->data_[i][j];
119 }
120
121 /**
122 * Return the value of a single element of this matrix.
123 * @return the value of a single element of this matrix
124 * @param i row index
125 * @param j Column index
126 */
127 Real operator()(unsigned int i, unsigned int j) const {
128 return this->data_[i][j];
129 }
130
131 /**
132 * Copy the internal data to an array
133 * @param array the pointer of destination array
134 */
135 void getArray(Real* array) {
136 for (unsigned int i = 0; i < Row; i++) {
137 for (unsigned int j = 0; j < Col; j++) {
138 array[i * Row + j] = this->data_[i][j];
139 }
140 }
141 }
142
143 /** Returns the pointer of internal array */
144 Real* getArrayPointer() { return &this->data_[0][0]; }
145
146 /**
147 * Returns a row of this matrix as a vector.
148 * @return a row of this matrix as a vector
149 * @param row the row index
150 */
151 Vector<Real, Row> getRow(unsigned int row) {
153
154 for (unsigned int i = 0; i < Col; i++)
155 v[i] = this->data_[row][i];
156
157 return v;
158 }
159
160 /**
161 * Sets a row of this matrix
162 * @param row the row index
163 * @param v the vector to be set
164 */
165 void setRow(unsigned int row, const Vector<Real, Row>& v) {
166 for (unsigned int i = 0; i < Col; i++)
167 this->data_[row][i] = v[i];
168 }
169
170 /**
171 * Returns a column of this matrix as a vector.
172 * @return a column of this matrix as a vector
173 * @param col the column index
174 */
175 Vector<Real, Col> getColumn(unsigned int col) {
177
178 for (unsigned int j = 0; j < Row; j++)
179 v[j] = this->data_[j][col];
180
181 return v;
182 }
183
184 /**
185 * Sets a column of this matrix
186 * @param col the column index
187 * @param v the vector to be set
188 */
189 void setColumn(unsigned int col, const Vector<Real, Col>& v) {
190 for (unsigned int j = 0; j < Row; j++)
191 this->data_[j][col] = v[j];
192 }
193
194 /**
195 * swap two rows of this matrix
196 * @param i the first row
197 * @param j the second row
198 */
199 void swapRow(unsigned int i, unsigned int j) {
200 assert(i < Row && j < Row);
201
202 for (unsigned int k = 0; k < Col; k++)
203 std::swap(this->data_[i][k], this->data_[j][k]);
204 }
205
206 /**
207 * swap two Columns of this matrix
208 * @param i the first Column
209 * @param j the second Column
210 */
211 void swapColumn(unsigned int i, unsigned int j) {
212 assert(i < Col && j < Col);
213
214 for (unsigned int k = 0; k < Row; k++)
215 std::swap(this->data_[k][i], this->data_[k][j]);
216 }
217
218 /**
219 * Tests if this matrix is identical to matrix m
220 * @return true if this matrix is equal to the matrix m, return false
221 * otherwise
222 * @param m matrix to be compared
223 *
224 * @todo replace operator == by template function equal
225 */
227 for (unsigned int i = 0; i < Row; i++)
228 for (unsigned int j = 0; j < Col; j++)
229 if (!equal(this->data_[i][j], m.data_[i][j])) return false;
230
231 return true;
232 }
233
234 /**
235 * Tests if this matrix is not equal to matrix m
236 * @return true if this matrix is not equal to the matrix m, return false
237 * otherwise
238 * @param m matrix to be compared
239 */
241 return !(*this == m);
242 }
243
244 /** Negates the value of this matrix in place. */
245 inline void negate() {
246 for (unsigned int i = 0; i < Row; i++)
247 for (unsigned int j = 0; j < Col; j++)
248 this->data_[i][j] = -this->data_[i][j];
249 }
250
251 /**
252 * Sets the value of this matrix to the negation of matrix m.
253 * @param m the source matrix
254 */
255 inline void negate(const RectMatrix<Real, Row, Col>& m) {
256 for (unsigned int i = 0; i < Row; i++)
257 for (unsigned int j = 0; j < Col; j++)
258 this->data_[i][j] = -m.data_[i][j];
259 }
260
261 /**
262 * Sets the value of this matrix to the sum of itself and m (*this += m).
263 * @param m the other matrix
264 */
265 inline void add(const RectMatrix<Real, Row, Col>& m) {
266 for (unsigned int i = 0; i < Row; i++)
267 for (unsigned int j = 0; j < Col; j++)
268 this->data_[i][j] += m.data_[i][j];
269 }
270
271 /**
272 * Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).
273 * @param m1 the first matrix
274 * @param m2 the second matrix
275 */
276 inline void add(const RectMatrix<Real, Row, Col>& m1,
277 const RectMatrix<Real, Row, Col>& m2) {
278 for (unsigned int i = 0; i < Row; i++)
279 for (unsigned int j = 0; j < Col; j++)
280 this->data_[i][j] = m1.data_[i][j] + m2.data_[i][j];
281 }
282
283 /**
284 * Sets the value of this matrix to the difference of itself and m (*this
285 * -= m).
286 * @param m the other matrix
287 */
288 inline void sub(const RectMatrix<Real, Row, Col>& m) {
289 for (unsigned int i = 0; i < Row; i++)
290 for (unsigned int j = 0; j < Col; j++)
291 this->data_[i][j] -= m.data_[i][j];
292 }
293
294 /**
295 * Sets the value of this matrix to the difference of matrix m1 and m2
296 * (*this = m1 - m2).
297 * @param m1 the first matrix
298 * @param m2 the second matrix
299 */
300 inline void sub(const RectMatrix<Real, Row, Col>& m1,
301 const RectMatrix<Real, Row, Col>& m2) {
302 for (unsigned int i = 0; i < Row; i++)
303 for (unsigned int j = 0; j < Col; j++)
304 this->data_[i][j] = m1.data_[i][j] - m2.data_[i][j];
305 }
306
307 /**
308 * Sets the value of this matrix to the scalar multiplication of itself
309 * (*this *= s).
310 * @param s the scalar value
311 */
312 inline void mul(Real s) {
313 for (unsigned int i = 0; i < Row; i++)
314 for (unsigned int j = 0; j < Col; j++)
315 this->data_[i][j] *= s;
316 }
317
318 /**
319 * Sets the value of this matrix to the scalar multiplication of matrix m
320 * (*this = s * m).
321 * @param s the scalar value
322 * @param m the matrix
323 */
324 inline void mul(Real s, const RectMatrix<Real, Row, Col>& m) {
325 for (unsigned int i = 0; i < Row; i++)
326 for (unsigned int j = 0; j < Col; j++)
327 this->data_[i][j] = s * m.data_[i][j];
328 }
329
330 /**
331 * Sets the value of this matrix to the scalar division of itself (*this /=
332 * s ).
333 * @param s the scalar value
334 */
335 inline void div(Real s) {
336 for (unsigned int i = 0; i < Row; i++)
337 for (unsigned int j = 0; j < Col; j++)
338 this->data_[i][j] /= s;
339 }
340
341 /**
342 * Sets the value of this matrix to the scalar division of matrix m (*this
343 * = m /s).
344 * @param s the scalar value
345 * @param m the matrix
346 */
347 inline void div(Real s, const RectMatrix<Real, Row, Col>& m) {
348 for (unsigned int i = 0; i < Row; i++)
349 for (unsigned int j = 0; j < Col; j++)
350 this->data_[i][j] = m.data_[i][j] / s;
351 }
352
353 /**
354 * Multiples a scalar into every element of this matrix.
355 * @param s the scalar value
356 */
358 this->mul(s);
359 return *this;
360 }
361
362 /**
363 * Divides every element of this matrix by a scalar.
364 * @param s the scalar value
365 */
367 this->div(s);
368 return *this;
369 }
370
371 /**
372 * Sets the value of this matrix to the sum of the other matrix and itself
373 * (*this += m).
374 * @param m the other matrix
375 */
378 add(m);
379 return *this;
380 }
381
382 /**
383 * Sets the value of this matrix to the differerence of itself and the other
384 * matrix (*this -= m)
385 * @param m the other matrix
386 */
389 sub(m);
390 return *this;
391 }
392
393 /** Return the transpose of this matrix */
396
397 for (unsigned int i = 0; i < Row; i++)
398 for (unsigned int j = 0; j < Col; j++)
399 result(j, i) = this->data_[i][j];
400
401 return result;
402 }
403
404 template<class MatrixType>
405 void setSubMatrix(unsigned int beginRow, unsigned int beginCol,
406 const MatrixType& m) {
407 assert(beginRow + m.getNRow() - 1 <= getNRow());
408 assert(beginCol + m.getNCol() - 1 <= getNCol());
409
410 for (unsigned int i = 0; i < m.getNRow(); ++i)
411 for (unsigned int j = 0; j < m.getNCol(); ++j)
412 this->data_[beginRow + i][beginCol + j] = m(i, j);
413 }
414
415 template<class MatrixType>
416 void getSubMatrix(unsigned int beginRow, unsigned int beginCol,
417 MatrixType& m) {
418 assert(beginRow + m.getNRow() - 1 <= getNRow());
419 assert(beginCol + m.getNCol() - 1 <= getNCol());
420
421 for (unsigned int i = 0; i < m.getNRow(); ++i)
422 for (unsigned int j = 0; j < m.getNCol(); ++j)
423 m(i, j) = this->data_[beginRow + i][beginCol + j];
424 }
425
426 unsigned int getNRow() const { return Row; }
427 unsigned int getNCol() const { return Col; }
428
429 Real frobeniusNorm() {
430 Real norm(0.0);
431 for (unsigned int i = 0; i < Row; i++) {
432 for (unsigned int j = 0; j < Col; j++) {
433 norm += pow(abs(this->data_[i][j]), 2);
434 }
435 }
436 return sqrt(norm);
437 }
438
439 protected:
440 Real data_[Row][Col];
441 };
442
443 /** Negate the value of every element of this matrix. */
444 template<typename Real, unsigned int Row, unsigned int Col>
448
449 result.negate();
450
451 return result;
452 }
453
454 /**
455 * Return the sum of two matrixes (m1 + m2).
456 * @return the sum of two matrixes
457 * @param m1 the first matrix
458 * @param m2 the second matrix
459 */
460 template<typename Real, unsigned int Row, unsigned int Col>
463 const RectMatrix<Real, Row, Col>& m2) {
465
466 result.add(m1, m2);
467
468 return result;
469 }
470
471 /**
472 * Return the difference of two matrixes (m1 - m2).
473 * @return the sum of two matrixes
474 * @param m1 the first matrix
475 * @param m2 the second matrix
476 */
477 template<typename Real, unsigned int Row, unsigned int Col>
480 const RectMatrix<Real, Row, Col>& m2) {
482
483 result.sub(m1, m2);
484
485 return result;
486 }
487
488 /**
489 * Return the multiplication of scalra and matrix (m * s).
490 * @return the multiplication of a scalra and a matrix
491 * @param m the matrix
492 * @param s the scalar
493 */
494 template<typename Real, unsigned int Row, unsigned int Col>
496 const RectMatrix<Real, Row, Col>& m, Real s) {
498
499 result.mul(s, m);
500
501 return result;
502 }
503
504 /**
505 * Return the multiplication of a scalra and a matrix (s * m).
506 * @return the multiplication of a scalra and a matrix
507 * @param s the scalar
508 * @param m the matrix
509 */
510 template<typename Real, unsigned int Row, unsigned int Col>
512 Real s, const RectMatrix<Real, Row, Col>& m) {
514
515 result.mul(s, m);
516
517 return result;
518 }
519
520 /**
521 * Return the multiplication of two matrixes (m1 * m2).
522 * @return the multiplication of two matrixes
523 * @param m1 the first matrix
524 * @param m2 the second matrix
525 */
526 template<typename Real, unsigned int Row, unsigned int Col,
527 unsigned int SameDim>
532
533 for (unsigned int i = 0; i < Row; i++)
534 for (unsigned int j = 0; j < Col; j++)
535 for (unsigned int k = 0; k < SameDim; k++)
536 result(i, j) += m1(i, k) * m2(k, j);
537
538 return result;
539 }
540
541 /**
542 * Returns the multiplication of a matrix and a vector (m * v).
543 * @return the multiplication of a matrix and a vector
544 * @param m the matrix
545 * @param v the vector
546 */
547 template<typename Real, unsigned int Row, unsigned int Col>
549 const Vector<Real, Col>& v) {
550 Vector<Real, Row> result;
551
552 for (unsigned int i = 0; i < Row; i++)
553 for (unsigned int j = 0; j < Col; j++)
554 result[i] += m(i, j) * v[j];
555
556 return result;
557 }
558
559 /**
560 * Returns the multiplication of a vector transpose and a matrix (v^T * m).
561 * @return the multiplication of a vector transpose and a matrix
562 * @param v the vector
563 * @param m the matrix
564 */
565 template<typename Real, unsigned int Row, unsigned int Col>
568 Vector<Real, Row> result;
569
570 for (unsigned int i = 0; i < Col; i++)
571 for (unsigned int j = 0; j < Row; j++)
572 result[i] += v[j] * m(j, i);
573
574 return result;
575 }
576
577 /**
578 * Return the scalar division of matrix (m / s).
579 * @return the scalar division of matrix
580 * @param m the matrix
581 * @param s the scalar
582 */
583 template<typename Real, unsigned int Row, unsigned int Col>
585 const RectMatrix<Real, Row, Col>& m, Real s) {
587
588 result.div(s, m);
589
590 return result;
591 }
592
593 /**
594 * Returns the tensor contraction (double dot product) of two rank 2
595 * tensors (or Matrices)
596 *
597 * \f[ \mathbf{A} \colon \! \mathbf{B} = \sum_\alpha \sum_\beta
598 * \mathbf{A}_{\alpha \beta} B_{\alpha \beta} \f]
599 *
600 * @param t1 first tensor
601 * @param t2 second tensor
602 * @return the tensor contraction (double dot product) of t1 and t2
603 */
604 template<typename Real, unsigned int Row, unsigned int Col>
606 const RectMatrix<Real, Row, Col>& t2) {
607 Real tmp;
608 tmp = 0;
609
610 for (unsigned int i = 0; i < Row; i++)
611 for (unsigned int j = 0; j < Col; j++)
612 tmp += t1(i, j) * t2(i, j);
613
614 return tmp;
615 }
616
617 /**
618 * Returns the vector (cross) product of two matrices. This
619 * operation is defined in:
620 *
621 * W. Smith, "Point Multipoles in the Ewald Summation (Revisited),"
622 * CCP5 Newsletter No 46., pp. 18-30.
623 *
624 * Equation 21 defines:
625 * \f[
626 * V_alpha = \sum_\beta \left[ A_{\alpha+1,\beta} * B_{\alpha+2,\beta}
627 -A_{\alpha+2,\beta} * B_{\alpha+2,\beta} \right]
628 * \f]
629
630 * where \f[\alpha+1\f] and \f[\alpha+2\f] are regarded as cyclic
631 * permuations of the matrix indices (i.e. for a 3x3 matrix, when
632 * \f[\alpha = 2\f], \f[\alpha + 1 = 3 \f], and \f[\alpha + 2 = 1 \f] ).
633 *
634 * @param t1 first matrix
635 * @param t2 second matrix
636 * @return the cross product (vector product) of t1 and t2
637 */
638 template<typename Real, unsigned int Row, unsigned int Col>
640 const RectMatrix<Real, Row, Col>& t2) {
641 Vector<Real, Row> result;
642 unsigned int i1;
643 unsigned int i2;
644
645 for (unsigned int i = 0; i < Row; i++) {
646 i1 = (i + 1) % Row;
647 i2 = (i + 2) % Row;
648 for (unsigned int j = 0; j < Col; j++) {
649 result[i] += t1(i1, j) * t2(i2, j) - t1(i2, j) * t2(i1, j);
650 }
651 }
652 return result;
653 }
654
655 /**
656 * Write to an output stream
657 */
658 template<typename Real, unsigned int Row, unsigned int Col>
659 std::ostream& operator<<(std::ostream& o,
661 for (unsigned int i = 0; i < Row; i++) {
662 o << "(";
663 for (unsigned int j = 0; j < Col; j++) {
664 o << m(i, j);
665 if (j != Col - 1) o << "\t";
666 }
667 o << ")" << std::endl;
668 }
669 return o;
670 }
671} // namespace OpenMD
672
673#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:81
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).