122 const std::array<std::array<double, 10>, 20>& A,
123 std::array<std::array<double, 10>, 20> B) {
125 std::cout <<
"Dimension of vector is less than number of vector, hence "
127 << c <<
" vectors are orthogonalised\n";
135 for (
int j = 0; j < c; j++)
140 std::array<double, 10>
142 for (
int i = 0; i < c; ++i) {
143 all_projection[i] = 0;
148 std::array<double, 10>
153 for (
int i = 0; i < c; ++i) {
154 temp[i] = B[l - 1][i] * factor;
156 for (
int j = 0; j < c; ++j) {
164 for (
int i = 0; i < c; ++i) {
182 std::array<std::array<double, 10>, 20> a1 = {
183 {{1, 0, 1, 0}, {1, 1, 1, 1}, {0, 1, 2, 1}}};
184 std::array<std::array<double, 10>, 20> b1 = {{0}};
186 numerical_methods::gram_schmidt::gram_schmidt(3, 4, a1, b1);
188 for (
int i = 0; i < 2; ++i) {
189 for (
int j = i + 1; j < 3; ++j) {
191 numerical_methods::gram_schmidt::dot_product(b1[i], b1[j], 4));
199 std::cout <<
"Vectors are linearly dependent\n";
201 std::cout <<
"Passed Test Case 1\n ";
203 std::array<std::array<double, 10>, 20> a2 = {{{3, 1}, {2, 2}}};
204 std::array<std::array<double, 10>, 20> b2 = {{0}};
206 numerical_methods::gram_schmidt::gram_schmidt(2, 2, a2, b2);
208 for (
int i = 0; i < 1; ++i) {
209 for (
int j = i + 1; j < 2; ++j) {
211 numerical_methods::gram_schmidt::dot_product(b2[i], b2[j], 2));
219 std::cout <<
"Vectors are linearly dependent\n";
221 std::cout <<
"Passed Test Case 2\n";
223 std::array<std::array<double, 10>, 20> a3 = {{{1, 2, 2}, {-4, 3, 2}}};
224 std::array<std::array<double, 10>, 20> b3 = {{0}};
226 numerical_methods::gram_schmidt::gram_schmidt(2, 3, a3, b3);
228 for (
int i = 0; i < 1; ++i) {
229 for (
int j = i + 1; j < 2; ++j) {
231 numerical_methods::gram_schmidt::dot_product(b3[i], b3[j], 3));
239 std::cout <<
"Vectors are linearly dependent\n";
241 std::cout <<
"Passed Test Case 3\n";
251 std::cout <<
"Enter the dimension of your vectors\n";
253 std::cout <<
"Enter the number of vectors you will enter\n";
256 std::array<std::array<double, 10>, 20>
258 std::array<std::array<double, 10>, 20> B = {
261 for (
int i = 0; i < r; ++i) {
262 std::cout <<
"Enter vector " << i + 1
264 for (
int j = 0; j < c; ++j) {
265 std::cout <<
"Value " << j + 1 <<
"th of vector: ";
271 numerical_methods::gram_schmidt::gram_schmidt(r, c, A, B);
275 for (
int i = 0; i < r - 1; ++i) {
276 for (
int j = i + 1; j < r; ++j) {
278 numerical_methods::gram_schmidt::dot_product(B[i], B[j], c));
288 std::cout <<
"Vectors are linearly dependent\n";