21 assert(matrixData !=
nullptr);
37 return m_numberOfRows;
53 if (bufferSize == 0) {
56 buffer[bufferSize-1] = 0;
58 if (currentChar >= bufferSize-1) {
61 buffer[currentChar++] =
'[';
62 if (currentChar >= bufferSize-1) {
66 buffer[currentChar++] =
'[';
67 if (currentChar >= bufferSize-1) {
71 if (currentChar >= bufferSize-1) {
75 buffer[currentChar++] =
',';
76 if (currentChar >= bufferSize-1) {
80 if (currentChar >= bufferSize-1) {
84 currentChar =
strlen(buffer);
85 if (currentChar >= bufferSize-1) {
88 buffer[currentChar++] =
']';
89 if (currentChar >= bufferSize-1) {
93 buffer[currentChar++] =
']';
94 buffer[currentChar] = 0;
110 delete [] childrenLayouts;
121 for (
int i = 0; i < dim; i++) {
136 T ** tempMat =
new T*[dim];
137 for (
int i = 0; i < dim; i++) {
138 tempMat[i] =
new T[dim];
142 for (
int i = 0; i < dim; i++) {
143 for (
int j = 0; j < dim; j++) {
146 tempMat[i][j] =
static_cast<const Complex<T> *
>(op)->toScalar();
151 for (
int i = 0; i < dim-1; i++) {
153 int rowWithPivot = i;
154 for (
int row = i+1; row < dim; row++) {
159 T valuePivot = tempMat[rowWithPivot][i];
162 for (
int i = 0; i < dim; i++) {
169 if (rowWithPivot != i) {
170 for (
int col = i; col < dim; col++) {
171 T temp = tempMat[i][col];
172 tempMat[i][col] = tempMat[rowWithPivot][col];
173 tempMat[rowWithPivot][col] = temp;
179 for (
int row = i+1; row < dim; row++) {
180 T factor = tempMat[row][i]/valuePivot;
181 for (
int col = i; col < dim; col++) {
182 tempMat[row][col] -= factor*tempMat[i][col];
186 det *= tempMat[dim-1][dim-1];
187 for (
int i = 0; i < dim; i++) {
201 T ** inv =
new T*[dim];
202 for (
int i = 0; i < dim; i++) {
203 inv[i] =
new T [2*dim];
205 for (
int i = 0; i < dim; i++) {
206 for (
int j = 0; j < dim; j++) {
209 inv[i][j] =
static_cast<const Complex<T> *
>(op)->toScalar();
211 for (
int j = dim; j < 2*dim; j++) {
212 inv[i][j] = (i+dim == j);
216 for (
int i = 0; i < dim; i++) {
218 int rowWithPivot = i;
219 for (
int row = i+1; row < dim; row++) {
224 T valuePivot = inv[rowWithPivot][i];
227 for (
int i = 0; i < dim; i++) {
234 if (rowWithPivot != i) {
235 for (
int col = i; col < 2*dim; col++) {
236 T temp = inv[i][col];
237 inv[i][col] = inv[rowWithPivot][col];
238 inv[rowWithPivot][col] = temp;
242 for (
int col = 0; col < 2*dim; col++) {
243 inv[i][col] /= valuePivot;
246 for (
int row = 0; row < dim; row++) {
250 T factor = inv[row][i];
251 for (
int col = 0; col < 2*dim; col++) {
252 inv[row][col] -= factor*inv[i][col];
257 for (
int i = 0; i < dim; i++) {
258 for (
int j = 0; j < dim; j++) {
262 for (
int i = 0; i < dim; i++) {
287 for (
int i = 0; i < dim; i++) {
288 for (
int j = 0; j < dim; j++) {
304 for (
int i = 0; i < dim; i++) {
305 for (
int j = 0; j < dim; j++) {
319 Expression * Matrix::templatedApproximate(
Context& context, AngleUnit angleUnit)
const {
325 delete operandEvaluation;
335 template Matrix* Matrix::createApproximateIdentity<float>(int);
336 template Matrix* Matrix::createApproximateIdentity<double>(int);
337 template Complex<float>* Matrix::createTrace<float>()
const;
338 template Complex<double>* Matrix::createTrace<double>()
const;
339 template Matrix* Matrix::createInverse<float>()
const;
340 template Matrix* Matrix::createInverse<double>()
const;
341 template Complex<float>* Matrix::createDeterminant<float>()
const;
342 template Complex<double>* Matrix::createDeterminant<double>()
const;
int numberOfColumns() const
Matrix * createInverse() const
int polynomialDegree(char symbolName) const override
Expression * approximate(Context &context, AngleUnit angleUnit=AngleUnit::Default) const
int writeTextInBuffer(char *buffer, int bufferSize, int numberOfSignificantDigits=PrintFloat::k_numberOfStoredSignificantDigits) const override
static Matrix * createIdentity(int dim)
Matrix * createTranspose() const
Matrix(MatrixData *matrixData)
Complex< T > * createDeterminant() const
Expression * clone() const override
const Expression ** m_operands
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
size_t strlen(const char *s)
const Expression *const * operands() const override
constexpr uint8_t numberOfColumns
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode=PrintFloat::Mode::Default, ComplexFormat complexFormat=ComplexFormat::Default) const
static Complex< T > Float(T x)
void setParent(Expression *parent)
void pilferOperands(const Expression ***newStorageAddress)
Type type() const override
constexpr uint8_t numberOfRows
int numberOfOperands() const override
Complex< T > * createTrace() const
const Expression * operand(int i) const
virtual Type type() const =0
static Matrix * createApproximateIdentity(int dim)
virtual int writeTextInBuffer(char *buffer, int bufferSize, int numberOfSignificantDigits=PrintFloat::k_numberOfStoredSignificantDigits) const =0