Пример #1
0
// Left multiplication of this matrix and another
Matriz Matriz::operator*(const Matriz& matrizB) {
	Matriz result(linhas, matrizB.get_colunas());
	double valor;
	for (int linha = 0; linha < linhas; ++linha) {
		for (int coluna = 0; coluna < matrizB.get_colunas(); ++coluna) {
			valor = 0;
			for (int k = 0; k < matrizB.get_linhas(); ++k) {
				valor += (this->mat[linha][k] * matrizB(k, coluna));
			}
			result(linha, coluna) = valor;
		}
	}
	return result;
}
Пример #2
0
Matriz Matriz::operator-(const Matriz& matrizB) {
	int linhas = matrizB.get_linhas();
	int colunas = matrizB.get_colunas();
	Matriz result(linhas, colunas);

	for (int i = 0; i < linhas; i++) {
		for (int j = 0; j < colunas; j++) {
			result(i, j) = this->mat[i][j] - matrizB(i, j);
		}
	}

	return result;
}
Пример #3
0
Matriz::Matriz(const Matriz& matrizB) {
	mat = matrizB.mat;
	linhas = matrizB.get_linhas();
	colunas = matrizB.get_colunas();
}