Hhow can I dynamically define an $n$ by $n$ tridiagonal matrix in maple

121 Views Asked by At

My colleages and I, for the past three days have being trying to define an $n$ by $n$ tridiagonal matrix in maple.

we try to use the toolbox provided in maple but we ran into a problem as the size of the matrix was too large.

1

There are 1 best solutions below

0
On

Try using BandMatrix in the LinearAlgebra package. For example, if $A$, $B$ and $C$ are lists of length $n-1$, $n$ and $n-1$ respectively, the tridiagonal matrix whose subdiagonal, diagonal and superdiagonal are $A$, $B$ and $C$ can be constructed by

LinearAlgebra:-BandMatrix([A,B,C]);

This is memory-efficient because it uses a "band" storage option: no memory is required to store the zeros outside of those three diagonals.