Arithmetic Vector Operations



Zero Vector / Basis Vectors

Zero Vector and Canonical Basis Vectors.

It is convenient to have routines to initialize a vector to either a zero vector, v = (vi) where
vi = 0 ∀i, or a canonical basis vector, vi = (vi,j) where vi,j = 0 ∀j≠i and vi,i = 1.

The function for setting a real vector to the zero vector is Zero_Vector( ) and the function for setting a complex vector to the zero vector is Zero_CVector( ). The function for setting a real vector to a canonical basis vector is Canonical_Basis_Vector( ) and the function for setting a complex vector to a canonical basis vector is Canonical_Basis_CVector( ).

Function List

  • void Zero_Vector( double *v, int n )

    Set the n-dimensional vector v to the zero vector, i.e. v[i] = 0 for all i.

  • void Canonical_Basis_Vector( double v[ ], int i, int n )

    Set the n-dimensional vector v to the ith canonical basis vector, i.e. vj = 0 if j ≠ i and
    vi = 1. If n ≤ 0 then v[0] = 1 regardless of the value of i. If n > 0 and i < 0 or i ≥ n, then v[i] is not set, i.e. v is set to the zero vector.

  • void Zero_CVector( double complex *v, int n )

    Set the n-dimensional complex vector v to the zero vector, i.e. v[i] = 0 for all i.

  • void Canonical_Basis_CVector( double complex v[ ], int i, int n )

    Set the n-dimensional complex vector v to the ith canonical basis vector, i.e. vj = 0 if
    j ≠ i and vi = 1. If n ≤ 0 then v[0] = 1 regardless of the value of i. If n > 0 and i < 0 or i ≥ n, then v[i] is not set, i.e. v is set to the zero vector.

C Source Code

C Test Code, Test Results, and Build Shell Script

  • The file, testzerovector_C.c, contains a test program of Zero_Vector( ). This test program requires the file zero_vector.c listed above.

  • The file, ZeroVector_CTest.txt, contains the results of the test program testzerovector_C.c.

  • The file, testzerovector_C.sh, contains the shell script used to compile, link, and execute the test program testzerovector_C.c.


  • The file, testcanonicalbasis_C.c, contains a test program of Canonical_Basis_Vector( ). This test program requires the file canonical_basis_vector.c listed above.

  • The file, CanonicalBasisVector_CTest.txt, contains the results of the test program testcanonicalbasis_C.c.

  • The file, testcanonicalbasis_C.sh, contains the shell script used to compile, link, and execute the test program testcanonicalbasis_C.c.


  • The file, testzerocvector_C.c, contains a test program of Zero_CVector( ). This test program requires the file zero_cvector.c listed above.

  • The file, ZeroCVector_CTest.txt, contains the results of the test program testzerocvector_C.c.

  • The file, testzerocvector_C.sh, contains the shell script used to compile, link, and execute the test program testzerocvector_C.c.


  • The file, testcanonicalcbasis_C.c, contains a test program of Canonical_Basis_CVector( ). This test program requires the file canonical_basis_cvector.c listed above.

  • The file, CanonicalBasisCVector_CTest.txt, contains the results of the test program testcanonicalcbasis_C.c.

  • The file, testcanonicalcbasis_C.sh, contains the shell script used to compile, link, and execute the test program testcanonicalcbasis_C.c.

NASM Source Code
For Linux gcc Users

Nasm Test Code, Test Results, and Build Shell Script

  • The file, testzerovector_A.c, contains a test program of Zero_Vector( ). This test program requires the file zero_vector.asm listed above.

  • The file, ZeroVector_ATest.txt, contains the results of the test program testzerovector_A.c.

  • The file, testzerovector_A.sh, contains the shell script used to compile, link, and execute the test program testzerovector_A.c.


  • The file, testcanonicalbasis_A.c, contains a test program of Canonical_Basis_Vector( ). This test program requires the file canonical_basis_vector.asm listed above.

  • The file, CanonicalBasisVector_ATest.txt, contains the results of the test program testcanonicalbasis_A.c.

  • The file, testcanonicalbasis_A.sh, contains the shell script used to compile, link, and execute the test program testcanonicalbasis_A.c.