#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 6_16.h 6_16h0.h 6_16h1.h 6_16h10.h 6_16h11.h 6_16h12.h 6_16h13.h 6_16h14.h 6_16h15.h 6_16h16.h 6_16h17.h 6_16h18.h 6_16h19.h 6_16h2.h 6_16h20.h 6_16h21.h 6_16h22.h 6_16h23.h 6_16h24.h 6_16h25.h 6_16h26.h 6_16h27.h 6_16h28.h 6_16h3.h 6_16h4.h 6_16h5.h 6_16h6.h 6_16h7.h 6_16h8.h 6_16h9.h makefile mat4.h mat4all.c tst.c tst.cmp # # To extract the files from this shell archive file simply # create a directory for this file, move the archive file # to it and enter the command # # sh filename # # The files will be extracted automatically. # Note: Do not use csh. # # Archive created: Mon Jul 30 23:06:47 EDT 1990 # echo x - 6_16.h sed 's/^X//' > 6_16.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ /* vector of four vec4's Exercise 6.16 */ #ifndef MAT4_H #define MAT4_H # include # include overload gauss; #include "6_16h0.h" // EXPAND class, ~mat4() mat4(); // mat4 x; // new mat4; mat4(mat4& a); // mat4 x = y; mat4(vec4 a); // mat4 x = v; mat4(float a); // mat4 x = 5.; mat4(int a); // mat4 x = 5; mat4(vec4 a, vec4 b, vec4 c, vec4 d); // mat4 x(a, b, c, d); mat4 operator=(mat4 a); // x = y; mat4 operator=(vec4 a); // x = v; mat4 operator=(float a); // x = 35.; mat4 operator=(int a); // x = 35; vec4& operator[](int i); // v = m[i] friend int operator==(mat4 a, mat4 b);// b = m == n friend int operator!=(mat4 a, mat4 b);// b = m != n friend mat4 operator+(mat4 a, mat4 b);// b = m + n friend mat4 operator-(mat4 a, mat4 b);// b = m - n friend mat4 operator+(mat4 a); // b = +m friend mat4 operator-(mat4 a); // b = -m mat4 operator+=(mat4 a); // m += n mat4 operator-=(mat4 a); // m -= n mat4 operator*=(mat4 a); // m *= n // matrix multiplication defined in terms // of dot products of the vectors friend mat4 operator*(mat4 a, mat4 b); // multiply the row-vector times the matrix friend vec4 operator*(vec4 a, mat4 b); // multiply the matrix times the column-vector friend vec4 operator*(mat4 a, vec4 b); friend mat4 operator*(mat4 a, float b);// b = m * 5. friend mat4 operator*(mat4 a, int b); // b = m * 5 // Do gaussian elimination on two matrices // Return 1 if succeeded, 0 if singular friend int gauss(mat4& a, mat4& b); // do gaussian elimination on a matrix & vector friend int gauss(mat4& a, vec4& b); // cout << m friend ostream& operator<< (ostream& out, mat4 a); }; #endif /* MAT4_H */ !EOF! ls -l 6_16.h echo x - 6_16h0.h sed 's/^X//' > 6_16h0.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ class mat4 { vec4 v[4]; public: ~mat4() {} // delete mat4; // ... !EOF! ls -l 6_16h0.h echo x - 6_16h1.h sed 's/^X//' > 6_16h1.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x; or new mat4; mat4::mat4() { v[0] = 0; v[1] = 0; v[2] = 0; v[3] = 0; } !EOF! ls -l 6_16h1.h echo x - 6_16h10.h sed 's/^X//' > 6_16h10.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // x = 35; mat4 mat4::operator=(int a) { v[0] = v[1] = v[2] = v[3] = a; return *this; } !EOF! ls -l 6_16h10.h echo x - 6_16h11.h sed 's/^X//' > 6_16h11.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // v = m[i] vec4& mat4::operator[](int i) { return v[(i > 0) && (i < 4) ? i : 0]; } !EOF! ls -l 6_16h11.h echo x - 6_16h12.h sed 's/^X//' > 6_16h12.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m == n int operator==(mat4 a, mat4 b) { int v0 = (a.v[0] == b.v[0]); int v1 = (a.v[1] == b.v[1]); int v2 = (a.v[2] == b.v[2]); int v3 = (a.v[3] == b.v[3]); return v0 && v1 && v2 && v3; } !EOF! ls -l 6_16h12.h echo x - 6_16h13.h sed 's/^X//' > 6_16h13.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m != n int operator!=(mat4 a, mat4 b) { int v0 = (a.v[0] != b.v[0]); int v1 = (a.v[1] != b.v[1]); int v2 = (a.v[2] != b.v[2]); int v3 = (a.v[3] != b.v[3]); return v0 || v1 || v2 || v3; } !EOF! ls -l 6_16h13.h echo x - 6_16h14.h sed 's/^X//' > 6_16h14.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // cout << m ostream& operator<< (ostream& out, mat4 a) { out << "("; out << a.v[0] << ","; out << a.v[1] << ","; out << a.v[2] << ","; out << a.v[3] << ")"; return out; } !EOF! ls -l 6_16h14.h echo x - 6_16h15.h sed 's/^X//' > 6_16h15.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m + n mat4 operator+(mat4 a, mat4 b) { mat4 ret(a.v[0] + b.v[0], a.v[1] + b.v[1], a.v[2] + b.v[2], a.v[3] + b.v[3]); return ret; } !EOF! ls -l 6_16h15.h echo x - 6_16h16.h sed 's/^X//' > 6_16h16.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m - n mat4 operator-(mat4 a, mat4 b) { mat4 ret(a.v[0] - b.v[0], a.v[1] - b.v[1], a.v[2] - b.v[2], a.v[3] - b.v[3]); return ret; } !EOF! ls -l 6_16h16.h echo x - 6_16h17.h sed 's/^X//' > 6_16h17.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = +m mat4 operator+(mat4 a) { mat4 ret = a; return ret; } !EOF! ls -l 6_16h17.h echo x - 6_16h18.h sed 's/^X//' > 6_16h18.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = -m mat4 operator-(mat4 a) { mat4 ret(-a.v[0], -a.v[1], -a.v[2], -a.v[3]); return ret; } !EOF! ls -l 6_16h18.h echo x - 6_16h19.h sed 's/^X//' > 6_16h19.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // matrix multiplication defined in terms // of dot products of the vectors mat4 operator*(mat4 a, mat4 b) { vec4 b_c0(b.v[0][0], b.v[1][0], b.v[2][0], b.v[3][0]); vec4 b_c1(b.v[0][1], b.v[1][1], b.v[2][1], b.v[3][1]); vec4 b_c2(b.v[0][2], b.v[1][2], b.v[2][2], b.v[3][2]); vec4 b_c3(b.v[0][3], b.v[1][3], b.v[2][3], b.v[3][3]); vec4 r_r0(a.v[0].dot(b_c0), a.v[0].dot(b_c1), a.v[0].dot(b_c2), a.v[0].dot(b_c2)); vec4 r_r1(a.v[1].dot(b_c0), a.v[1].dot(b_c1), a.v[1].dot(b_c2), a.v[1].dot(b_c2)); vec4 r_r2(a.v[2].dot(b_c0), a.v[2].dot(b_c1), a.v[2].dot(b_c2), a.v[2].dot(b_c2)); vec4 r_r3(a.v[3].dot(b_c0), a.v[3].dot(b_c1), a.v[3].dot(b_c2), a.v[3].dot(b_c2)); mat4 ret(r_r0, r_r1, r_r2, r_r3); return ret; } !EOF! ls -l 6_16h19.h echo x - 6_16h2.h sed 's/^X//' > 6_16h2.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x = y; mat4::mat4(mat4& a) { v[0] = a.v[0]; v[1] = a.v[1]; v[2] = a.v[2]; v[3] = a.v[3]; } !EOF! ls -l 6_16h2.h echo x - 6_16h20.h sed 's/^X//' > 6_16h20.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // m += n mat4 mat4::operator+=(mat4 a) { v[0] += a.v[0]; v[1] += a.v[1]; v[2] += a.v[2]; v[3] += a.v[3]; return *this; } !EOF! ls -l 6_16h20.h echo x - 6_16h21.h sed 's/^X//' > 6_16h21.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // m -= n mat4 mat4::operator-=(mat4 a) { v[0] -= a.v[0]; v[1] -= a.v[1]; v[2] -= a.v[2]; v[3] -= a.v[3]; return *this; } !EOF! ls -l 6_16h21.h echo x - 6_16h22.h sed 's/^X//' > 6_16h22.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // m *= n mat4 mat4::operator*=(mat4 a) { vec4 a_c0(a.v[0][0], a.v[1][0], a.v[2][0], a.v[3][0]); vec4 a_c1(a.v[0][1], a.v[1][1], a.v[2][1], a.v[3][1]); vec4 a_c2(a.v[0][2], a.v[1][2], a.v[2][2], a.v[3][2]); vec4 a_c3(a.v[0][3], a.v[1][3], a.v[2][3], a.v[3][3]); vec4 r_r0(v[0].dot(a_c0), v[0].dot(a_c1), v[0].dot(a_c2), v[0].dot(a_c2)); vec4 r_r1(v[1].dot(a_c0), v[1].dot(a_c1), v[1].dot(a_c2), v[1].dot(a_c2)); vec4 r_r2(v[2].dot(a_c0), v[2].dot(a_c1), v[2].dot(a_c2), v[2].dot(a_c2)); vec4 r_r3(v[3].dot(a_c0), v[3].dot(a_c1), v[3].dot(a_c2), v[3].dot(a_c2)); *this = mat4(r_r0, r_r1, r_r2, r_r3); return *this; } !EOF! ls -l 6_16h22.h echo x - 6_16h23.h sed 's/^X//' > 6_16h23.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // multiply the row-vector times the matrix vec4 operator*(vec4 a, mat4 b) { vec4 ret(a.dot(b.v[0]), a.dot(b.v[1]), a.dot(b.v[2]), a.dot(b.v[3])); return ret; } !EOF! ls -l 6_16h23.h echo x - 6_16h24.h sed 's/^X//' > 6_16h24.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // multiply the matrix times the column-vector vec4 operator*(mat4 a, vec4 b) { vec4 ret(a.v[0].dot(b), a.v[1].dot(b), a.v[2].dot(b), a.v[3].dot(b)); return ret; } !EOF! ls -l 6_16h24.h echo x - 6_16h25.h sed 's/^X//' > 6_16h25.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m * 5. mat4 operator*(mat4 a, float b) { a.v[0] *= b; a.v[1] *= b; a.v[2] *= b; a.v[3] *= b; return a; } !EOF! ls -l 6_16h25.h echo x - 6_16h26.h sed 's/^X//' > 6_16h26.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // b = m * 5 mat4 operator*(mat4 a, int b) { a.v[0] *= b; a.v[1] *= b; a.v[2] *= b; a.v[3] *= b; return a; } !EOF! ls -l 6_16h26.h echo x - 6_16h27.h sed 's/^X//' > 6_16h27.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include // Do gaussian elimination on two matrices // Return 1 if succeeded, 0 if singular int gauss(mat4& a, mat4& b) { for (int diag = 0; diag < 4; diag++) { // check for zero diagonal element if (a.v[diag][diag] == 0) { // look for non-zero element for (int row = diag + 1; row < 4; row++) if (a.v[diag][row] != 0) { // found one, swap into diagonal for (int col = 0; col < 4; col++) swap(a.v[col][row], a.v[col][diag]); for (col = 0; col < 4; col++) swap(b.v[col][row], b.v[col][diag]); break; } // none available? if (row == 4) // return with what we have return 0; } // reduce each row below // the diagonal element for (int row = diag + 1; row < 4; row++) { float multiplier = a.v[diag][row] / a.v[diag][diag]; // subtracting should give // zero, so just set it for (int col = 0; col < diag; col++) a.v[col][row] = 0.0; // reduce the row on the left for ( ; col < 4; col++) a.v[col][row] -= a.v[col][0] * multiplier; // reduce the row on the right for (col = 0; col < 4; col++) b.v[col][row] -= b.v[col][0] * multiplier; } } return 1; } !EOF! ls -l 6_16h27.h echo x - 6_16h28.h sed 's/^X//' > 6_16h28.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // do gaussian elimination on a matrix & vector int gauss(mat4& a, vec4& b) { mat4 mb = b; int ret = gauss(a, mb); b = mb.v[0]; return ret; } !EOF! ls -l 6_16h28.h echo x - 6_16h3.h sed 's/^X//' > 6_16h3.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x = v; mat4::mat4(vec4 a) { v[0] = v[1] = v[2] = v[3] = a; } !EOF! ls -l 6_16h3.h echo x - 6_16h4.h sed 's/^X//' > 6_16h4.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x = 5.; mat4::mat4(float a) { v[0] = v[1] = v[2] = v[3] = a; } !EOF! ls -l 6_16h4.h echo x - 6_16h5.h sed 's/^X//' > 6_16h5.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x = 5; mat4::mat4(int a) { v[0] = v[1] = v[2] = v[3] = a; } !EOF! ls -l 6_16h5.h echo x - 6_16h6.h sed 's/^X//' > 6_16h6.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // mat4 x(a, b, c, d); mat4::mat4(vec4 a, vec4 b, vec4 c, vec4 d) { v[0] = a; v[1] = b; v[2] = c; v[3] = d; } !EOF! ls -l 6_16h6.h echo x - 6_16h7.h sed 's/^X//' > 6_16h7.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // x = y; mat4 mat4::operator=(mat4 a) { v[0] = a.v[0]; v[1] = a.v[1]; v[2] = a.v[2]; v[3] = a.v[3]; return *this; } !EOF! ls -l 6_16h7.h echo x - 6_16h8.h sed 's/^X//' > 6_16h8.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // x = v; mat4 mat4::operator=(vec4 a) { v[0] = v[1] = v[2] = v[3] = a; return *this; } !EOF! ls -l 6_16h8.h echo x - 6_16h9.h sed 's/^X//' > 6_16h9.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // x = 35.; mat4 mat4::operator=(float a) { v[0] = v[1] = v[2] = v[3] = a; return *this; } !EOF! ls -l 6_16h9.h echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC CFLAGS= -I../6.15dir all: tst tst: tst.c 6_16.h 6_16h0.h 6_16h1.h 6_16h10.h 6_16h11.h 6_16h12.h 6_16h13.h \ 6_16h14.h 6_16h15.h 6_16h16.h 6_16h17.h 6_16h18.h 6_16h19.h 6_16h2.h 6_16h20.h \ 6_16h21.h 6_16h22.h 6_16h23.h 6_16h24.h 6_16h25.h 6_16h26.h 6_16h27.h 6_16h28.h \ 6_16h3.h 6_16h4.h 6_16h5.h 6_16h6.h 6_16h7.h 6_16h8.h 6_16h9.h mat4.h $(CC) $(CFLAGS) tst.c -o tst CMP= tst.cmp OUT= tst.out tst.out: tst ; tst > tst.out test: all $(OUT) $(CMP) cmp tst.out tst.cmp echo tests done !EOF! ls -l makefile echo x - mat4.h sed 's/^X//' > mat4.h << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include "6_16.h" !EOF! ls -l mat4.h echo x - mat4all.c sed 's/^X//' > mat4all.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include "6_16h1.h" #include "6_16h2.h" #include "6_16h3.h" #include "6_16h4.h" #include "6_16h5.h" #include "6_16h6.h" #include "6_16h7.h" #include "6_16h8.h" #include "6_16h9.h" #include "6_16h10.h" #include "6_16h11.h" #include "6_16h12.h" #include "6_16h13.h" #include "6_16h14.h" #include "6_16h15.h" #include "6_16h16.h" #include "6_16h17.h" #include "6_16h18.h" #include "6_16h19.h" #include "6_16h20.h" #include "6_16h21.h" #include "6_16h22.h" #include "6_16h23.h" #include "6_16h24.h" #include "6_16h25.h" #include "6_16h26.h" #include "6_16h27.h" #include "6_16h28.h" !EOF! ls -l mat4all.c echo x - tst.c sed 's/^X//' > tst.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include "mat4.h" #include "mat4all.c" #include "vec4all.h" main() { mat4 a; cout << "a=\n" << a << "\n"; mat4 b = 5; cout << "b=\n" << b << "\n"; mat4 c = (float) 6.; cout << "c=\n" << c << "\n"; mat4 d = c; cout << "d=\n" << d << "\n"; vec4 v1(1., 2., 3., 4.); cout << "v1=\n" << v1 << "\n"; mat4 e = v1; cout << "e=\n" << e << "\n"; cout << "e[1]=\n" << e[1] << "\n"; cout << "e[1][3]=\n" << e[1][3] << "\n"; mat4 f(v1,v1,v1,v1); cout << "f=\n" << f << "\n"; a = b; cout << "a=\n" << a << "\n"; a = v1; cout << "a=\n" << a << "\n"; a = 5; cout << "a=\n" << a << "\n"; cout << "a == b ? " << (a == b) << "\n"; cout << "a != b ? " << (a != b) << "\n"; cout << "a == c ? " << (a == c) << "\n"; cout << "a != c ? " << (a != c) << "\n"; a = (float) 23.5; cout << "a=\n" << a << "\n"; a = b + c; cout << "a=b+c=\n" << a << "\n"; a = b - c; cout << "a=b-c=\n" << a << "\n"; a = +b; cout << "a= +b=\n" << a << "\n"; a = -b; cout << "a= -b=\n" << a << "\n"; a += c; cout << "a += c=\n" << a << "\n"; a -= d; cout << "a -= d=\n" << a << "\n"; a *= b; cout << "a *= b=\n" << a << "\n"; a = b * c; cout << "a=b*c=\n" << a << "\n"; a = v1 * c; cout << "a=v1*c=\n" << a << "\n"; a = b * v1; cout << "a=b*v1=\n" << a << "\n"; b = 0; b[1][1] = 1; b[2][2] = 1; b[3][3] = 1; b[4][4] = 1; cout << "b=\n" << b << "\n"; c = a; int ret = gauss(a, b); cout << "a=\n" << a << "\n"; cout << "b=\n" << b << "\n"; cout << "ret=" << ret << "\n"; a = c; v1 = 0; ret = gauss(a, v1); cout << "a=\n" << a << "\n"; cout << "v1=\n" << v1 << "\n"; cout << "ret=" << ret << "\n"; return 0; } !EOF! ls -l tst.c echo x - tst.cmp sed 's/^X//' > tst.cmp << '!EOF!' a= ((0,0,0,0),(0,0,0,0),(0,0,0,0),(0,0,0,0)) b= ((5,5,5,5),(5,5,5,5),(5,5,5,5),(5,5,5,5)) c= ((6,6,6,6),(6,6,6,6),(6,6,6,6),(6,6,6,6)) d= ((6,6,6,6),(6,6,6,6),(6,6,6,6),(6,6,6,6)) v1= (1,2,3,4) e= ((1,2,3,4),(1,2,3,4),(1,2,3,4),(1,2,3,4)) e[1]= (1,2,3,4) e[1][3]= 4 f= ((1,2,3,4),(1,2,3,4),(1,2,3,4),(1,2,3,4)) a= ((5,5,5,5),(5,5,5,5),(5,5,5,5),(5,5,5,5)) a= ((1,2,3,4),(1,2,3,4),(1,2,3,4),(1,2,3,4)) a= ((5,5,5,5),(5,5,5,5),(5,5,5,5),(5,5,5,5)) a == b ? 1 a != b ? 0 a == c ? 0 a != c ? 1 a= ((23.5,23.5,23.5,23.5),(23.5,23.5,23.5,23.5),(23.5,23.5,23.5,23.5),(23.5,23.5,23.5,23.5)) a=b+c= ((11,11,11,11),(11,11,11,11),(11,11,11,11),(11,11,11,11)) a=b-c= ((-1,-1,-1,-1),(-1,-1,-1,-1),(-1,-1,-1,-1),(-1,-1,-1,-1)) a= +b= ((5,5,5,5),(5,5,5,5),(5,5,5,5),(5,5,5,5)) a= -b= ((-5,-5,-5,-5),(-5,-5,-5,-5),(-5,-5,-5,-5),(-5,-5,-5,-5)) a += c= ((1,1,1,1),(1,1,1,1),(1,1,1,1),(1,1,1,1)) a -= d= ((-5,-5,-5,-5),(-5,-5,-5,-5),(-5,-5,-5,-5),(-5,-5,-5,-5)) a *= b= ((-100,-100,-100,-100),(-100,-100,-100,-100),(-100,-100,-100,-100),(-100,-100,-100,-100)) a=b*c= ((120,120,120,120),(120,120,120,120),(120,120,120,120),(120,120,120,120)) a=v1*c= ((60,60,60,60),(60,60,60,60),(60,60,60,60),(60,60,60,60)) a=b*v1= ((50,50,50,50),(50,50,50,50),(50,50,50,50),(50,50,50,50)) b= ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)) a= ((50,0,0,0),(50,0,0,0),(50,0,0,0),(50,0,0,0)) b= ((1,-1,-1,-1),(0,1,0,0),(0,0,1,0),(0,0,0,1)) ret=0 a= ((50,0,0,0),(50,0,0,0),(50,0,0,0),(50,0,0,0)) v1= (0,0,0,0) ret=0 !EOF! ls -l tst.cmp # The following exit is to ensure that extra garbage # after the end of the shar file will be ignored. exit 0