vendredi 28 décembre 2018

Gauss-Seidel method and coupled gradient methods for matrix

I have matrix https://i.ibb.co/P4Zm2rG/matrix.png and I should write code using Gauss-Seidl and coupled gradient methods taking the structure of the matrix.

Ax = e where A - is matrix and e is vector with only 1 values

I don't know how to write code using coupled gradient methods. And my Gauss-Seidel algorithm don't have main part where I add this all thinks

//part of gauss-seidel method

const int N = 128;               //size of matrix
const int no_of_iter = 128; //iterations
int main(){
  double result[N];     //tab for result
  double result_pom[N]; //tmp result tab
  double sum = 0.0;    //

  int x, y;                            
  for (int i = 0; i < no_of_iter; i++) {
    for (y = 0; y < N; y++)
       result_pom[y] = result[y]; //set values of result to result_pom

    for (x = 0; x < N; x++){
      sum = 0.0;
      //for functions where I add (x,y) el

      result[x] = 0.25 * (1 - sum);//because 4 is dominant el of matrix and 1 is value of vector e
    }
  }

}

Aucun commentaire:

Enregistrer un commentaire