block_bandsolve: Solve linear system when the matrix is block-wise with a band...

Description Usage Arguments Value Examples

Description

Solve linear system when the matrix is block-wise with a band diagonal block

Usage

1
block_bandsolve(mat, vect, mat_as_rotated = FALSE, lim = NULL)

Arguments

mat

Square matrix

vect

Vector of same length as mat

lim

Positive integer

Value

The vector mat ^ -1 vect is returned. If mat[lim:end, lim:end] is not a band matrix or if mat is symmetric, an error is returned. If these two conditions are met, the returned value is the same as solve(mat, vect). There might be nummerical impercision errors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
## With mat_as_rotated = FALSE
set.seed(0)
A <- matrix(rnorm(36), 6, 6)
B <- matrix(rnorm(24), 6, 4)
D <- diag(rnorm(4)) + rbind(cbind(0, diag(rnorm(3))), 0)
mat <- rbind(cbind(A + t(A), B),
                     cbind(t(B), D + t(D)))
vect <- rnorm(10)
lim <- 6
max(block_bandsolve(mat, vect, lim) - solve(mat, vect))

## With mat_as_rotated = TRUE
set.seed(0)
A <- matrix(rnorm(36), 6, 6)
B <- matrix(rnorm(24), 6, 4)
D <- cbind(rnorm(4), c(rnorm(3), 0))
mat_rotated <- list('A' = A + t(A),
            'B' = B,
            'D' = D)
mat <- rbind(cbind(mat_rotated$A, mat_rotated$B),
                     cbind(t(mat_rotated$B), rot2mat(mat_rotated$D)))
vect <- rnorm(10)
max(block_bandsolve(mat_rotated, vect, mat_as_rotated = TRUE) - solve(mat, vect))

## End(Not run)

goepp/hazreg documentation built on June 7, 2019, 4:03 a.m.