Revision 364879d2

View differences:

utility/matrix.h
117 117
    }
118 118

  
119 119

  
120
    Matrix operator + (Matrix m)
120
    Matrix operator+(const Matrix& m) const
121 121
    {
122 122
        Matrix ret;
123
        for(int x = 0; x < N; x++)
123
        for (int ij = 0; ij < N*N; ++ij)
124 124
        {
125
            for(int y = 0; y < N; y++)
126
            {
127
                ret._cell[x*N+y] = _cell[x*N+y] + m._cell[x*N+y];
128
            }
125
            ret._cell_data[ij] = _cell_data[ij] + m._cell_data[ij];
129 126
        }
130 127
        return ret;
131 128
    }
132 129

  
133
    Matrix operator - (Matrix m)
130
    Matrix operator-(const Matrix& m) const
134 131
    {
135 132
        Matrix ret;
136
        for(int x = 0; x < N; x++)
133
        for (int ij = 0; ij < N*N; ++ij)
137 134
        {
138
            for(int y = 0; y < N; y++)
139
            {
140
                ret._cell[x*N+y] = _cell[x*N+y] - m._cell[x*N+y];
141
            }
135
            ret._cell_data[ij] = _cell_data[ij] - m._cell_data[ij];
142 136
        }
143 137
        return ret;
144 138
    }
145 139

  
146
    Matrix operator * (double scalar)
140
    Matrix operator*(double scalar) const
147 141
    {
148 142
        Matrix ret;
149
        for(int x = 0; x < N; x++)
143
        for (int ij = 0; ij < N*N; ++ij)
150 144
        {
151
            for(int y = 0; y < N; y++)
152
            {
153
                ret._cell[x*N+y] = _cell[x*N+y] * scalar;
154
            }
145
            ret._cell_data[ij] = _cell_data[ij] * scalar;
155 146
        }
156 147
        return ret;
157 148
    }

Also available in: Unified diff