4.7 External variables 117
-0.35276
0.49945
-0.19718
One more projection?
1
Projected vector at stage: 5
-0.18376
0.61676
-0.36129
0.608
-0.29267
One more projection?
0
Problems
4.6.1.Write a function that returns the Cartesian norm of a vector,
L 2 =
√
v[1]^2 +v[2]^2 +···+v[n]^2.
4.6.2.Write a function that returns thep-norm of a vector,
Lp=(v[1]p+v[2]p+···+v[n]p)^1 /p,
wherepis a specified real number.
4.6.3.Write a function that computes and passes to the main function the
transpose of a two-dimensional matrix. IfA[i][j]is an arbitrarym×n
matrix, its transpose is anothern×mmatrix whose elements are defined
as:B[i][j]=A[j][i].
4.6.4.Run themappingcode to assess the fate of the vector as the iterations
continue.
4.7 Externalvariables
Assume that a code has been split into two files, one file containing the main
program and the second file containing a function. Moreover, assume that the
global integer variablekokorasis defined and possibly evaluated in the first file
before the implementation of the main function.
The same global variable cannot be defined in the second file, or the
linker may throw an exception on multiple variable definitions. However, if the
variable is not defined in the second file, the individual compilation of this file
will fail.