Node.h 2.07 KB
 JasonPries committed Dec 27, 2016 1 2 3 4 5 ``````#ifndef OERSTED_NODE_H #define OERSTED_NODE_H // TODO: Const `````` JasonPries committed Feb 05, 2017 6 7 ``````#include `````` JasonPries committed Feb 25, 2017 8 9 ``````#include "Mesh.hpp" `````` JasonPries committed Dec 27, 2016 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ``````template class SmallVector { private: double Value[N]; }; template class SmallMatrix { }; template class SquareMatrix : public SmallMatrix { }; template<> class SmallVector<2> { public: SmallVector() : Value{} {}; SmallVector(double x, double y) : Value{x, y} {}; `````` JasonPries committed Mar 08, 2017 31 32 33 34 `````` SmallVector(SmallVector<2> const &v) : Value{v.x(), v.y()} {}; SmallVector(Point const& p) : Value{p.X, p.Y} {}; `````` JasonPries committed Dec 27, 2016 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 `````` double value(size_t i) const { return Value[i]; }; double x() const { return Value[0]; }; void x(double val) { Value[0] = val; }; double y() const { return Value[1]; }; void y(double val) { Value[1] = val; }; private: double Value[2]; }; using XY = SmallVector<2>; template<> class SmallVector<3> { public: SmallVector() : Value{} {}; SmallVector(double x, double y, double z) : Value{x, y, z} {}; `````` JasonPries committed Mar 08, 2017 58 59 `````` SmallVector(SmallVector<3> const &v) : Value{v.x(), v.y(), v.z()} {}; `````` JasonPries committed Dec 27, 2016 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 `````` double value(size_t i) const { return Value[i]; } double x() const { return Value[0]; } double y() const { return Value[1]; } double z() const { return Value[2]; } private: double Value[3]; }; using XYZ = SmallVector<3>; template<> class SquareMatrix<2, true> { public: SquareMatrix() : Value{} {}; SquareMatrix(double xx, double xy, double yy) : Value{xx, xy, yy} {}; double xx() const { return Value[0]; }; double xy() const { return Value[1]; }; double yx() const { return Value[1]; }; double yy() const { return Value[2]; }; private: double Value[3]; }; template<> class SquareMatrix<2, false> { public: SquareMatrix() : Value{} {}; SquareMatrix(double xx, double xy, double yx, double yy) : Value{xx, xy, yx, yy} {}; double xx() const { return Value[0]; }; double xy() const { return Value[1]; }; double yx() const { return Value[2]; }; double yy() const { return Value[3]; }; private: double Value[4]; }; #endif //OERSTED_NODE_H``````