bdSolve

bdSolve

LINEAR_ALGEBRA

1 Description

Solves the linear system AX = B where A is an N-by-N matrix and X and B are N-by-NRHS matrices. The function automatically detects if A is symmetric and uses the appropriate solver.

2 Usage

bdSolve(A, B)

3 Arguments

Parameter Description
A Numeric matrix. The coefficient matrix (must be square).
B Numeric matrix. The right-hand side matrix (must have same number of rows as A).

4 Value

Numeric matrix X, the solution to AX = B.

5 Details

This function provides an efficient implementation for solving linear systems using LAPACK routines. Key features: - Automatic detection of matrix properties: - Checks for matrix symmetry - Selects optimal solver based on matrix structure - Solver selection: - Symmetric systems: Uses LAPACK’s dsysv routine - Non-symmetric systems: Uses LAPACK’s dgesv routine - Performance optimizations: - Automatic workspace sizing - Efficient memory management - Support for multiple right-hand sides

The implementation ensures: - Robust error handling - Efficient memory usage - Numerical stability - Support for various matrix sizes

6 Examples

library(BigDataStatMeth)

# Create test matrices
n <- 500
m <- 500

A <- matrix(runif(n*m), nrow = n, ncol = m)
B <- matrix(runif(n), nrow = n)
AS <- A %*% t(A)  # Create symmetric matrix

# Solve using bdSolve
X <- bdSolve(A, B)

# Compare with R's solve
XR <- solve(A, B)
all.equal(X, XR, check.attributes=FALSE)

7 See Also

  • bdSolve_hdf5 for solving systems with HDF5-stored matrices
  • solve for R’s built-in solver