solve_ols: Solving Linear Systems

Description Usage Arguments Value Examples

Description

This function solves a linear system using Gauss-Seidel, Jacobi method, or Jacobi (parallel) method.

Usage

1
solve_ols(A, b, x0, method, ncores)

Arguments

A

= a symmetric matrix

b

= a vector

x0

= initial vector for iterative process

method

= one of three methods: "Gauss-Seidel", "Jacobi", or "Jacobi-Parallel"

Value

a list with x, the final estimated vector, and total_iter, the number of iterations

Examples

1
2
3
4
5
6
7
A3 = tridiagonal(3, -1, 100)
v = rep(c(1, 0), times=50)
b3 = A3%*%v

solve_ols(A=A3, b=b3, x0=rep(0, nrow(A3)), method="Gauss-Seidel")
solve_ols(A=A3, b=b3, x0=rep(0, nrow(A3)), method="Jacobi")
solve_ols(A=A3, b=b3, x0=rep(0, nrow(A3)), method="Jacobi-Parallel")

gdeng96/Homework2 documentation built on June 5, 2019, 11:07 p.m.