Guest User

Untitled

a guest
Dec 22nd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. Matrix Matrix::splitScene(int i, int j) //Split image into blocks
  2. {
  3.  
  4. int endingRow = 49+i; //49+i
  5. int endingCol = 36+j; //36+j
  6.  
  7. double* tempData = new double[49*36];
  8.  
  9. int count = 0;
  10.  
  11. for (int x = i; x < endingRow; x++)
  12. {
  13. for (int y = j; y < endingCol; y++)
  14. {
  15. tempData[count] = _data[(y*_N)+x];
  16. count++;
  17. }
  18. }
  19.  
  20. Matrix temp(49, 36, tempData);
  21.  
  22. delete[] tempData;
  23. return temp;
  24. }
  25.  
  26.  
  27.  
  28. double* Matrix::getData() //getting data
  29. {
  30.  
  31. return _data;
  32. }
  33.  
  34. void Matrix::set(double* inputData) //sets pixels for each block based on ssd data
  35. {
  36. int number=0;
  37. for (int i = 0; i < 49; i++)
  38. {
  39. for (int j = 0; j < 36; j++)
  40. {
  41. _data[(i * _N) + j] = inputData[number];
  42. number++;
  43. }
  44. }
  45.  
  46. delete [] inputData;
  47. }
  48.  
  49.  
  50. Matrix Matrix::operator=(const Matrix& other)
  51. {
  52. delete[] _data;
  53. _M = other._M;
  54. _N = other._N;
  55.  
  56. _data = new double[_M*_N];
  57.  
  58. for (int i = 0; i < (_M*_N); i++)
  59. {
  60. this->_data[i] = other._data[i];
  61. }
  62. return *this;
  63. }
  64.  
  65.  
  66. Matrix Matrix::operator*(const Matrix& other)
  67. {
  68. for (int i = 0; i < (_M*_N); i++)
  69. {
  70. this->_data[i] = this->_data[i] * other._data[i];
  71. }
  72.  
  73. return *this;
  74. }
  75.  
  76. Matrix Matrix::operator-(const Matrix& other) //overload allowing -ing of matrices
  77. {
  78.  
  79. for (int i = 0; i < (_M*_N); i++)
  80. {
  81. this->_data[i] = this->_data[i] - other._data[i];
  82. }
  83.  
  84. return *this;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment