4 #include <fmatvec/fmatvec.h>
5 #include <mbsim/mbsim_event.h>
31 Point<N>::Point(Vector<Fixed<N>,
double> pnt) :
32 Vector<Fixed<N>, double>(pnt) {
66 HPoint<N>::HPoint(Vector<Fixed<N + 1>,
double> pnt) :
67 Vector<Fixed<N + 1>, double>(pnt) {
71 HPoint<N>::~HPoint() {
75 Point<N> HPoint<N>::projectW() {
77 for (
int i = 0; i < N; i++)
83 double HPoint<N>::w() {
88 double HPoint<N>::w()
const {
94 Point<N> project(
const HPoint<N> & hPnt) {
96 for (
int i = 0; i < N; i++)
97 pnt(i) = hPnt(i) / hPnt.w();
104 template <
typename T>
114 T& operator()(
int i,
int j);
115 T
const& operator()(
int i,
int j)
const;
118 void resize(
int nrows_,
int ncols_);
119 template <
typename J>
120 friend std::ostream& operator<<(std::ostream &os, const GeneralMatrix<J> &A);
126 template <
typename T>
128 nrows(0), ncols(0), data(NULL) {
131 template <
typename T>
132 inline GeneralMatrix<T>::GeneralMatrix(
int nrows_,
int ncols_) :
133 nrows(nrows_), ncols(ncols_) {
134 if (nrows_ == 0 || ncols_ == 0)
135 throw MBSim::MBSimError(
"(GeneralMatrix:: The number of rows or columns of the matrix is zero!)");
136 data =
new T[nrows_ * ncols_];
138 template <
typename T>
139 inline GeneralMatrix<T>::GeneralMatrix(
const GeneralMatrix<T>& m) :
140 nrows(m.nrows), ncols(m.ncols) {
141 data =
new T[nrows * ncols];
142 std::copy(m.data, m.data + nrows * ncols, data);
145 template <
typename T>
146 inline GeneralMatrix<T>::~GeneralMatrix() {
150 template <
typename T>
151 inline GeneralMatrix<T>& GeneralMatrix<T>::operator=(
const GeneralMatrix<T>& m) {
158 template <
typename T>
159 inline T& GeneralMatrix<T>::operator()(
int row,
int col) {
160 if (row >= nrows || col >= ncols)
161 throw MBSim::MBSimError(
"(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 MBSim::MBSimError(
"(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 MBSim::MBSimError(
"(GeneralMatrix::resize(): non-positive resize number of rows or columns!)");
190 if (nrows_ == nrows && ncols_ == ncols)
193 T* 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:43
wrapper class for nurbs type Point
Definition: nurbs_defs.h:13
RowVector< Ref, AT > trans(const Vector< Ref, AT > &x)
basic error class for mbsim
Definition: mbsim_event.h:38
wrapper class for nurbs surface interpolating data point
Definition: nurbs_defs.h:105