Guest User

Untitled

a guest
Feb 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include "LinArray.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. double* LinArray::getInd(int i){
  7. return &arr[i];
  8. };
  9.  
  10. double LinArray::getInd(int i, int j){
  11. return arr[transformIndex(i,j)];
  12. };
  13.  
  14. void LinArray::setInd(int i, double val){
  15. arr[i]=val;
  16. };
  17.  
  18. void LinArray::setInd(int i, int j, double val){
  19. arr[transformIndex(i,j)]=val;
  20. };
  21.  
  22. int LinArray::transformIndex(int i, int j){
  23. return i+j*lda;
  24. };
  25.  
  26. void LinArray::generateArray(int n, bool withoutVals){
  27. arr = new double[lda*lda];
  28. if(!withoutVals)fillArray(n);
  29. };
  30.  
  31. void LinArray::fillArray(int n){
  32. for(int i=0; i<n;i++){
  33. for(int j=0;j<n;j++){
  34. double num = static_cast<double>( rand() ) * RAND_MAX / static_cast<double>( RAND_MAX );
  35. arr[transformIndex(i,j)]=num;
  36. }
  37. }
  38. };
Add Comment
Please, Sign In to add comment