summaryrefslogtreecommitdiffstats
path: root/debian/fireflies/fireflies-2.08/libgfx/src/symmat3.cxx
blob: 36c684e31bb82e5042263f6a3199cf1f881b21de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <gfx/gfx.h>
#include <gfx/symmat3.h>

namespace gfx
{

SymMat3 SymMat3::I()
{
    SymMat3 A;
    A(0,0) = A(1,1) = A(2,2) = 1;
    return A;
}

Mat3 SymMat3::fullmatrix() const
{
    Mat3 A;

    for(int i=0; i<A.dim(); i++)
	for(int j=0; j<A.dim(); j++)
	    A(i, j) = (*this)(i,j);

    return A;
}

SymMat3 operator*(const SymMat3& n, const SymMat3& m)
{
    SymMat3 A;
    for(int i=0; i<3; i++)  for(int j=i; j<3; j++)
	    A(i,j) = n.row(i)*m.col(j);
    return A;
}

std::ostream &operator<<(std::ostream &out, const SymMat3& M)
{
    for(int i=0; i<M.dim(); i++)
    {
	for(int j=0; j<M.dim(); j++)
	    out << M(i, j) << " ";
	out << std::endl;
    }

    return out;
}

SymMat3 SymMat3::outer_product(const Vec3& v)
{
    SymMat3 A;

    for(int i=0; i<A.dim(); i++)
	for(int j=i; j<A.dim(); j++)
	    A(i, j) = v[i]*v[j];

    return A;
}

double invert(Mat3& m_inv, const SymMat3& m)
{
    return invert(m_inv, m.fullmatrix());
}

} // namespace gfx