Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 7a748be4 authored by Sadr Mohsen's avatar Sadr Mohsen
Browse files

Reblace Tenzor with boost::matrix in MSLang.h and AffineTransformation.h

parent 453de685
No related branches found
No related tags found
No related merge requests found
...@@ -2,20 +2,46 @@ ...@@ -2,20 +2,46 @@
#define MSLANG_AFFINETRANSFORMATION_H #define MSLANG_AFFINETRANSFORMATION_H
#include "Algorithms/Vektor.h" #include "Algorithms/Vektor.h"
#include "AppTypes/Tenzor.h" //#include "AppTypes/Tenzor.h"
#include "Algorithms/Matrix.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
namespace mslang { namespace mslang {
struct AffineTransformation: public Tenzor<double, 3> { //struct AffineTransformation: public Tenzor<double, 3> {
//AffineTransformation(const Vector_t& row0,
// const Vector_t& row1):
// Tenzor(row0[0], row0[1], row0[2], row1[0], row1[1], row1[2], 0.0, 0.0, 1.0) {
//}
struct AffineTransformation: public matrix_t {
AffineTransformation(const Vector_t& row0, AffineTransformation(const Vector_t& row0,
const Vector_t& row1): const Vector_t& row1):
Tenzor(row0[0], row0[1], row0[2], row1[0], row1[1], row1[2], 0.0, 0.0, 1.0) { matrix_t(3,3){
} (*this)(0, 0) = row0[0];
(*this)(0, 1) = row0[1];
(*this)(0, 2) = row0[2];
(*this)(1, 0) = row1[0];
(*this)(1, 1) = row1[1];
(*this)(1, 2) = row1[2];
(*this)(2, 0) = 0.0;
(*this)(2, 1) = 0.0;
(*this)(2, 2) = 1.0;
}
AffineTransformation(): AffineTransformation():
Tenzor(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) { } matrix_t(3,3){
(*this)(0, 0) = 1.0;
(*this)(0, 1) = 0.0;
(*this)(0, 2) = 0.0;
(*this)(1, 0) = 0.0;
(*this)(1, 1) = 1.0;
(*this)(1, 2) = 0.0;
(*this)(2, 0) = 0.0;
(*this)(2, 1) = 0.0;
(*this)(2, 2) = 1.0;
}
// Tenzor(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) { }
AffineTransformation getInverse() const { AffineTransformation getInverse() const {
AffineTransformation Ret; AffineTransformation Ret;
...@@ -42,11 +68,19 @@ namespace mslang { ...@@ -42,11 +68,19 @@ namespace mslang {
} }
Vector_t transformTo(const Vector_t &v) const { Vector_t transformTo(const Vector_t &v) const {
const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3>* >(this); //const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3>* >(this);
Vector_t b(v[0], v[1], 1.0); //Vector_t b(v[0], v[1], 1.0);
Vector_t w = dot(A, b); //Vector_t w = dot(A, b);
//return Vector_t(w(0]), w(1), 0.0);
return Vector_t(w[0], w[1], 0.0); matrix_t b = matrix_t(3, 1); // Create a 3x1 matrix for b
b(0, 0) = v(0);
b(1, 0) = v(1);
b(2, 0) = 1.0;
// Vector_t w = dot(A, b);
matrix_t w = boost::numeric::ublas::prod(*this, b);
return Vector_t(w(0, 0), w(1, 0), 0.0);
} }
Vector_t transformFrom(const Vector_t &v) const { Vector_t transformFrom(const Vector_t &v) const {
...@@ -55,16 +89,25 @@ namespace mslang { ...@@ -55,16 +89,25 @@ namespace mslang {
} }
AffineTransformation mult(const AffineTransformation &B) { AffineTransformation mult(const AffineTransformation &B) {
//AffineTransformation Ret;
//const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3> *>(this);
//const Tenzor<double, 3> &BTenz = *static_cast<const Tenzor<double, 3> *>(&B);
//Tenzor<double, 3> &C = *static_cast<Tenzor<double, 3> *>(&Ret);
//C = dot(A, BTenz);
//return Ret;
AffineTransformation Ret; AffineTransformation Ret;
const Tenzor<double, 3> &A = *static_cast<const Tenzor<double, 3> *>(this); matrix_t &A = *this;
const Tenzor<double, 3> &BTenz = *static_cast<const Tenzor<double, 3> *>(&B); const matrix_t &BTenz = B;
Tenzor<double, 3> &C = *static_cast<Tenzor<double, 3> *>(&Ret); matrix_t &C = Ret;
C = dot(A, BTenz); C = boost::numeric::ublas::prod(A, BTenz);
return Ret; return Ret;
} }
}; };
} }
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment