Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "matrixadt.h"
- #include <iostream>
- using namespace std;
- MatrixADT::MatrixADT()
- {
- }
- void MatrixADT::create(int eixoX,int eixoY){
- this->eixoX = eixoX;
- this->eixoY = eixoY;
- this->mtz[eixoX][eixoY];
- }
- void MatrixADT::setElementAt(int eixoX,int eixoY,double value){
- this->mtz[eixoX][eixoY] = value;
- }
- double MatrixADT::getElementAt(int eixoX,int eixoY)
- {
- return this->mtz[eixoX][eixoY];
- }
- void MatrixADT::multiplyBy(double k){
- for(int i; i < this->eixoX;i++){
- for(int j; j < this->eixoY;j++)
- {
- this->mtz[i][j] *= k;
- }
- }
- }
- double MatrixADT::determinant()
- {
- switch (this->eixoX) {
- case 3:
- return ((this->mtz[1][1]*this->mtz[2][2]*this->mtz[3][3]) + (this->mtz[1][2]*this->mtz[2][3]*this->mtz[1][3]) + (this->mtz[3][3]*this->mtz[2][1]*this->mtz[3][2]))-((this->mtz[1][3]*this->mtz[2][2]*this->mtz[3][1]) + (this->mtz[1][1]*this->mtz[2][3]*this->mtz[3][2]) + (this->mtz[1][2]*this->mtz[2][1]*this->mtz[3][3]));
- break;
- default:
- break;
- }
- }
- QString MatrixADT::toString(){
- for(int i = 0;i < this->eixoX;i++)
- {
- for(int j = 0;i < this->eixoY ;j++){
- cout << mtz[i][j] << " ";
- if(i == this->eixoX - 1){
- cout << "\n";
- }
- }
- }
- }
- MatrixADT *MatrixADT::transpose(){
- int aux;
- for(int i = 0;i < this->eixoX;i++)
- {
- for(int j = 0;i < this->eixoY;j++){
- aux = this->mtz[i][j];
- this->mtz[i][j] = this->mtz[j][i];
- this->mtz[j][i] = aux;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement