|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "cnumber.hpp"
|
|
|
|
|
#include "vector.hpp"
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <string>
|
|
|
|
@ -73,14 +75,40 @@ public:
|
|
|
|
|
if (!m.is_invertible()) {
|
|
|
|
|
m.err = true;
|
|
|
|
|
} else {
|
|
|
|
|
for (uint64_t i = 0; i < m.get_num_entries(); i++) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// switch row i with row j
|
|
|
|
|
const matrix exchange_row(uint64_t i, uint64_t j) {
|
|
|
|
|
matrix m = *this;
|
|
|
|
|
vector v = m.get_entry(i);
|
|
|
|
|
m[i] = m[j];
|
|
|
|
|
m[j] = v;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
// subtract row i from row j
|
|
|
|
|
const matrix subtract_row(uint64_t i, uint64_t j, cnumber multiplier = 1) {
|
|
|
|
|
matrix m = *this;
|
|
|
|
|
m[j] = m[j] - (m.multiply_row(i, multiplier)[i]);
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
// add row i to row j
|
|
|
|
|
const matrix add_row(uint64_t i, uint64_t j, cnumber multiplier = 1) {
|
|
|
|
|
matrix m = *this;
|
|
|
|
|
m[j] = m[j] + (m.multiply_row(i, multiplier)[i]);
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Multiply row by z
|
|
|
|
|
const matrix multiply_row(uint64_t i, cnumber z) {
|
|
|
|
|
matrix m = *this;
|
|
|
|
|
m[i] = m[i] * z;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
const vector get_entry(uint64_t index) const { return this->entries[index]; }
|
|
|
|
|
|
|
|
|
|
const vector get_row(uint64_t index) const {
|
|
|
|
|
const vector get_column(uint64_t index) const {
|
|
|
|
|
vector v(this->entry_dimension);
|
|
|
|
|
for (uint64_t j = 0; j < this->entry_dimension; j++) {
|
|
|
|
|
v[j] = this->entries[j][index];
|
|
|
|
@ -246,7 +274,7 @@ public:
|
|
|
|
|
}
|
|
|
|
|
for (uint64_t i = 0; i < this->entry_dimension; i++) {
|
|
|
|
|
for (uint64_t j = 0; j < this->entry_dimension; j++) {
|
|
|
|
|
n[i][j] = this->get_entry(i) * m.get_row(j);
|
|
|
|
|
n[i][j] = this->get_entry(i) * m.get_column(j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|