Advertisement
Loesome

.cpp

Mar 24th, 2014
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include "matrixadt.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. MatrixADT::MatrixADT()
  7. {
  8.  
  9.  
  10. }
  11.  
  12.  
  13. void MatrixADT::create(int eixoX,int eixoY){
  14. this->eixoX = eixoX;
  15. this->eixoY = eixoY;
  16. this->mtz[eixoX][eixoY];
  17. }
  18. void MatrixADT::setElementAt(int eixoX,int eixoY,double value){
  19. this->mtz[eixoX][eixoY] = value;
  20. }
  21.  
  22. double MatrixADT::getElementAt(int eixoX,int eixoY)
  23. {
  24. return this->mtz[eixoX][eixoY];
  25. }
  26. void MatrixADT::multiplyBy(double k){
  27. for(int i; i < this->eixoX;i++){
  28. for(int j; j < this->eixoY;j++)
  29. {
  30. this->mtz[i][j] *= k;
  31. }
  32. }
  33. }
  34. double MatrixADT::determinant()
  35. {
  36. switch (this->eixoX) {
  37. case 3:
  38. 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]));
  39.  
  40. break;
  41. default:
  42. break;
  43. }
  44. }
  45.  
  46. QString MatrixADT::toString(){
  47. for(int i = 0;i < this->eixoX;i++)
  48. {
  49. for(int j = 0;i < this->eixoY ;j++){
  50.  
  51. cout << mtz[i][j] << " ";
  52.  
  53. if(i == this->eixoX - 1){
  54. cout << "\n";
  55. }
  56. }
  57. }
  58. }
  59. MatrixADT *MatrixADT::transpose(){
  60. int aux;
  61. for(int i = 0;i < this->eixoX;i++)
  62. {
  63. for(int j = 0;i < this->eixoY;j++){
  64. aux = this->mtz[i][j];
  65. this->mtz[i][j] = this->mtz[j][i];
  66. this->mtz[j][i] = aux;
  67. }
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement