411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0eh
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void x_dif_sizes_mR(
double **A,
double **B,
char function[],
char matrices[]
)
{
if( A[R_SIZE][C0]!=B[R_SIZE][C0]
||
A[C_SIZE][C0]!=B[C_SIZE][C0] )
{
printf("\n Error : %s\n",function);
printf("\n The matrices %s must have the same size. \n",matrices);
stop();
exit(EXIT_FAILURE);
}
}
/* ------------------------------------ */
int main(void)
{
double **A = i_mR(R4,R3);
double **B = i_mR(R4,R6);
clrscrn();
printf(" A[R%d,C%d]:",rsize_R(A),csize_R(A));
p_mR(A, S4,P0,C6);
printf(" B[R%d,C%d]:",rsize_R(B),csize_R(B));
p_mR(B, S4,P0,C6);
dif_sizes_mR(A,B,"add_mR();","(A and B)");
f_mR(A);
f_mR(B);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The dif_sizes_mR(); function checks if the matrices are of the same size.
Example of use: add_mR();, f_eigs_mR();|
Screen output example:
A[R4,C3]:
+0 +0 +0
+0 +0 +0
+0 +0 +0
+0 +0 +0
B[R4,C6]:
+0 +0 +0 +0 +0 +0
+0 +0 +0 +0 +0 +0
+0 +0 +0 +0 +0 +0
+0 +0 +0 +0 +0 +0
Error : add_mR();
The matrices (A and B) must have the same size.
Press return to continue.