Revision d964148c utility/matrix.h

View differences:

utility/matrix.h
1 1
/*
2 2
    Inertial Measurement Unit Maths Library
3 3
    Copyright (C) 2013-2014  Samuel Cowen
4
	www.camelsoftware.com
4
    www.camelsoftware.com
5 5

  
6 6
    This program is free software: you can redistribute it and/or modify
7 7
    it under the terms of the GNU General Public License as published by
......
32 32
template <uint8_t N> class Matrix
33 33
{
34 34
public:
35
	Matrix()
36
	{
37
		int r = sizeof(double)*N;
38
        _cell = (double*)malloc(r*r);
35
    Matrix()
36
    {
37
        int r = sizeof(double)*N;
38
        _cell = &_cell_data[0];
39 39
        memset(_cell, 0, r*r);
40
	}
40
    }
41 41

  
42 42
    Matrix(const Matrix &v)
43 43
    {
44 44
        int r = sizeof(double)*N;
45
        _cell = (double*)malloc(r*r);
45
        _cell = &_cell_data[0];
46 46
        memset(_cell, 0, r*r);
47 47
        for (int x = 0; x < N; x++ )
48 48
        {
......
55 55

  
56 56
    ~Matrix()
57 57
    {
58
        free(_cell);
59 58
    }
60 59

  
61 60
    void operator = (Matrix m)
......
239 238

  
240 239
private:
241 240
    double* _cell;
241
    double  _cell_data[N*N];
242 242
};
243 243

  
244 244

  

Also available in: Unified diff