solve_ols: solve_ols

Description Usage Arguments Value Examples

Description

Solve linear system by Gauss-Seidel, Jacobi(sequential), or Jacobi(parallel) method

Usage

1
solve_ols(A, b, cores = 1, method, iteration)

Arguments

A

n*n matrix of the input system Ax=b

b

n*1 vector of the input system Ax=b

cores

Number of cores used in parallel computing of Jacobi Mathod. If cores=1,use sequential method, otherwise use parallel computing.

method

Method to use. "GS"=Gauss-Seidel,"Jacobi"=Jacobi

iteration

Number of iterations

Value

x,n*1 vector, solution of the input system Ax=b

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
n=10
L <- diag(0, n)
L[(row(L) - col(L)) == 1] <- -1
U <- diag(0, n)
U[(row(U) - col(U)) == -1] <- -1
D <- diag(2, n)
a <- L+D+U
v <- as.matrix(rep(1,10))
b=a%*%v
solve_ols(a,b,method = "GS",iteration = 100)
solve_ols(a,b,cores=1,method = "Jacobi",iteration=100)
solve_ols(a,b,cores=2,method = "Jacobi",iteration=100)

xyzou685/STSCI6520_HW2 documentation built on June 6, 2019, 2:29 p.m.