mat_add_band (complex)

Adds two band matrices, both in band storage mode, C ←αAβB.

Synopsis

#include <imsl.h>

f_complex *imsl_c_mat_add_band (int n, int nlca, int nuca, f_complex alpha, f_complex a[], int nlcb, int nucb, f_complex beta, f_complex b[], int *nlcc, int *nucc, ..., 0)

The type d_complex function is imsl_z_mat_add_band.

Required Arguments

int n (Input)
The order of the matrices A and B.

int nlca (Input)
Number of lower codiagonals of A.

int nuca (Input)
Number of upper codiagonals of A.

f_complex alpha (Input)
Scalar multiplier for A.

f_complex a[] (Input)
An n by n band matrix with nlca lower codiagonals and nuca upper codiagonals stored in band mode with dimension (nlca + nuca + 1) by n.

int nlcb (Input)
Number of lower codiagonals of B.

int nucb (Input)
Number of upper codiagonals of B.

f_complex beta (Input)
Scalar multiplier for B.

f_complex b[] (Input)
An n by n band matrix with nlcb lower codiagonals and nucb upper codiagonals stored in band mode with dimension (nlcb + nucb + 1) by n.

int *nlcc (Output)
Number of lower codiagonals of C.

int *nucc (Output)
Number of upper codiagonals of C.

Return Value

A pointer to an array of type f_complex containing the computed sum. In the event of an error or if the return matrix has no nonzero elements, NULL is returned.

Synopsis with Optional Arguments

#include <imsl.h>

f_complex *imsl_c_mat_add_band (int n, int nlca, int nuca, f_complex alpha, f_complex a[], int nlcb, int nucb, f_complex beta, f_complex b[], int *nlcc, int *nucc,

IMSL_A_TRANSPOSE,

IMSL_B_TRANSPOSE,

IMSL_A_CONJUGATE_TRANSPOSE,

IMSL_B_CONJUGATE_TRANSPOSE,

IMSL_SYMMETRIC,

0)

Optional Arguments

IMSL_A_TRANSPOSE,
Replace A with AT in the expression αA + βB.

IMSL_B_TRANSPOSE,
Replace B with BT in the expression αA + βB.

IMSL_A_CONJUGATE_TRANSPOSE,
Replace A with AH in the expression αA + βB.

IMSL_B_CONJUGATE_TRANSPOSE,
Replace B with BH in the expression αA + βB.

IMSL_SYMMETRIC,
Matrix A, B, and C are stored in band symmetric storage mode.

Description

The function imsl_c_mat_add_band forms the sum αA + βB, given the scalars α and β, and the matrices A and B in band format. The transpose or conjugate transpose of A and/or B may be used during the computation if optional arguments are specified. Symmetric storage mode may be used if the optional argument is specified.

If IMSL_SYMMETRIC is specified, the return value for the number of lower codiagonals, nlcc, will be equal to 0.

If the return matrix equals NULL, the return value for the number of lower codiagonals, nlcc, will be equal to -1 and the number of upper codiagonals, nucc, will be equal to 0.

Examples

 

Example 1

Add two complex matrices of order 4 stored in band mode. Matrix A has one upper codiagonal and one lower codiagonal. Matrix B has no upper codiagonals and two lower codiagonals.

 

#include <imsl.h>

 

int main()

{

f_complex a[] =

{{0.0, 0.0}, {2.0, 1.0}, {3.0, 3.0}, {-1.0, 0.0},

{1.0, 1.0}, {1.0, 3.0}, {1.0, -2.0}, {1.0, 5.0},

{0.0, 0.0}, {3.0, -2.0}, {4.0, 0.0}, {0.0, 0.0}};

f_complex b[] =

{{3.0, 1.0}, {3.0, 5.0}, {3.0, -1.0}, {3.0, 1.0},

{1.0, -3.0}, {-2.0, 0.0}, {1.0, 2.0}, {0.0, 0.0},

{-1.0, 4.0}, {2.0, 1.0}, {0.0, 0.0}, {0.0, 0.0}};

int nucb = 0, nlcb = 2;

int nuca = 1, nlca = 1;

int nucc, nlcc;

int n = 4, m;

f_complex *c;

f_complex alpha = {1.0, 0.0};

f_complex beta = {1.0, 0.0};

 

c = imsl_c_mat_add_band(n, nlca, nuca, alpha, a,

nlcb, nucb, beta, b,

&nlcc, &nucc, 0);

m = nlcc + nucc + 1;

imsl_c_write_matrix("C = A + B", m, n, c, 0);

imsl_free(c);

}

Output

 

C = A + B

1 2 3

1 ( 0, 0) ( 2, 1) ( 3, 3)

2 ( 4, 2) ( 4, 8) ( 4, -3)

3 ( 1, -3) ( 1, -2) ( 5, 2)

4 ( -1, 4) ( 2, 1) ( 0, 0)

 

4

1 ( -1, 0)

2 ( 4, 6)

3 ( 0, 0)

4 ( 0, 0)

Example 2

Compute

(3 + 2i)AH + (4 + i) BH

where

 

#include <imsl.h>

 

int main()

{

f_complex a[] =

{{0.0, 0.0}, {1.0, 3.0}, {3.0, 1.0}, {2.0, 5.0},

{2.0, 3.0}, {6.0, 2.0}, {4.0, 1.0}, {1.0, 2.0}};

f_complex b[] =

{{0.0, 0.0}, {5.0, 1.0}, {2.0, 3.0}, {4.0, 2.0},

{1.0, 2.0}, {1.0, 3.0}, {3.0, 2.0}, {1.0, 4.0},

{4.0, 1.0}, {2.0, 3.0}, {2.0, 6.0}, {0.0, 0.0}};

int nuca = 1, nlca = 0;

int nucb = 1, nlcb = 1;

int n = 4, m, nlcc, nucc;

f_complex *c;

f_complex alpha = {3.0, 2.0};

f_complex beta = {4.0, 1.0};

c = imsl_c_mat_add_band(n, nlca, nuca, alpha, a,

nlcb, nucb, beta, b,

&nlcc, &nucc,

IMSL_A_CONJUGATE_TRANSPOSE,

IMSL_B_CONJUGATE_TRANSPOSE, 0);

 

m = nlcc + nucc + 1;

imsl_c_write_matrix("C = (3+2i)*ctrans(A) + (4+i)*ctrans(B)\n",

m, n, c, 0);

imsl_free(c);

}

Output

C = (3+2i)*ctrans(A) + (4+i)*ctrans(B)

 

1 2 3

1 ( 0, 0) ( 17, 0) ( 11, -10)

2 ( 18, -12) ( 29, -5) ( 28, 0)

3 ( 30, -6) ( 22, -7) ( 34, -15)

 

4

1 ( 14, -22)

2 ( 15, -19)

3 ( 0, 0)