4#include <fmatvec/fmatvec.h>
5#include <mbsim/mbsim_event.h>
13 class Point :
public Vector<Fixed<N>, double> {
17 Point(Vector<Fixed<N>,
double> pnt);
26 Vector<Fixed<N>, double>() {
31 Point<N>::Point(Vector<Fixed<N>,
double> pnt) :
32 Vector<Fixed<N>, double>(pnt) {
36 Point<N>::~Point() =
default;
42 class HPoint :
public Vector<Fixed<N + 1>, double> {
46 HPoint(Vector<Fixed<N + 1>,
double> pnt);
61 Vector<Fixed<N + 1>, double>() {
65 HPoint<N>::HPoint(Vector<Fixed<N + 1>,
double> pnt) :
66 Vector<Fixed<N + 1>, double>(pnt) {
70 HPoint<N>::~HPoint() =
default;
73 Point<N> HPoint<N>::projectW() {
75 for (
int i = 0; i < N; i++)
81 double HPoint<N>::w() {
86 double HPoint<N>::w()
const {
92 Point<N> project(
const HPoint<N> & hPnt) {
94 for (
int i = 0; i < N; i++)
95 pnt(i) = hPnt(i) / hPnt.w();
102 template <
typename T>
103 class GeneralMatrix {
106 GeneralMatrix(
int nrows_,
int ncols_);
107 GeneralMatrix(
const GeneralMatrix<T>& m);
110 GeneralMatrix<T>& operator=(
const GeneralMatrix<T>& m);
112 T& operator()(
int row,
int col);
113 T
const& operator()(
int row,
int col)
const;
116 void resize(
int nrows_,
int ncols_);
117 template <
typename J>
118 friend std::ostream& operator<<(std::ostream &os,
const GeneralMatrix<J> &A);
120 int nrows{0}, ncols{0};
124 template <
typename T>
125 inline GeneralMatrix<T>::GeneralMatrix() :
129 template <
typename T>
130 inline GeneralMatrix<T>::GeneralMatrix(
int nrows_,
int ncols_) :
131 nrows(nrows_), ncols(ncols_) {
132 if (nrows_ == 0 || ncols_ == 0)
133 throw std::runtime_error(
"(GeneralMatrix:: The number of rows or columns of the matrix is zero!)");
134 data =
new T[nrows_ * ncols_];
136 template <
typename T>
137 inline GeneralMatrix<T>::GeneralMatrix(
const GeneralMatrix<T>& m) :
138 nrows(m.nrows), ncols(m.ncols) {
139 data =
new T[nrows * ncols];
140 std::copy(m.data, m.data + nrows * ncols, data);
143 template <
typename T>
144 inline GeneralMatrix<T>::~GeneralMatrix() {
148 template <
typename T>
149 inline GeneralMatrix<T>& GeneralMatrix<T>::operator=(
const GeneralMatrix<T>& m) {
153 data =
new T[nrows * ncols];
154 std::copy(m.data, m.data + nrows * ncols, data);
158 template <
typename T>
159 inline T& GeneralMatrix<T>::operator()(
int row,
int col) {
160 if (row >= nrows || col >= ncols)
161 throw std::runtime_error(
"(GeneralMatrix::operator(): trying to access data out of range of the GeneralMatrix!)");
162 return data[row * ncols + col];
165 template <
typename T>
166 inline T
const& GeneralMatrix<T>::operator()(
int row,
int col)
const {
167 if (row >= nrows || col >= ncols)
168 throw std::runtime_error(
"(GeneralMatrix::operator(): trying to access data out of range of the GeneralMatrix!)");
169 return data[row * ncols + col];
172 template <
typename T>
173 inline int GeneralMatrix<T>::rows()
const {
177 template <
typename T>
178 inline int GeneralMatrix<T>::cols()
const {
182 template <
typename T>
183 void GeneralMatrix<T>::resize(
int nrows_,
int ncols_) {
185 if (nrows_ <= 0 || ncols_ <= 0) {
186 throw std::runtime_error(
"(GeneralMatrix::resize(): non-positive resize number of rows or columns!)");
190 if (nrows_ == nrows && ncols_ == ncols)
193 auto* newData =
new T[nrows_ * ncols_];
201 template <
typename T>
202 std::ostream& operator<<(std::ostream &os,
const GeneralMatrix<T> &A) {
203 os << A.rows() <<
" x " << A.cols() << std::endl;
204 os <<
" = " << std::endl;
206 for (
int i = 0; i < A.rows(); ++i) {
207 for (
int j = 0; j < A.cols(); ++j) {
208 os << trans(A.data[i * A.ncols + j]);
210 if (i != A.rows() - 1)
211 os << std::endl <<
" ";
wrapper class for nurbs type HPoint
Definition: nurbs_defs.h:42
wrapper class for nurbs type Point
Definition: nurbs_defs.h:13