validation.cpu

C API

vector sum

teachcompute.validation.cpu._validation.vector_add(v1: numpy.ndarray[numpy.float32], v2: numpy.ndarray[numpy.float32]) numpy.ndarray[numpy.float32]

Computes the addition of 2 vectors of any dimensions. It assumes both vectors have the same dimensions (no broadcast).).

Paramètres:
  • v1 – first vector

  • v2 – second vector

Renvoie:

new vector

See vector_sum.cpp.

teachcompute.validation.cpu._validation.vector_sum(n_columns: int, values: List[float], by_rows: bool) float

Computes the sum of all elements in an array by rows or by columns. This function is slower than vector_sum_array as this function copies the data from an array to a std::vector. This copy (and allocation) is bigger than the compution itself.

Paramètres:
  • n_columns – number of columns

  • values – all values in an array

  • by_rows – by rows or by columns

Renvoie:

sum of all elements

See vector_sum.cpp.

teachcompute.validation.cpu._validation.vector_sum_array(n_columns: int, values: numpy.ndarray[numpy.float32], by_rows: bool) float

Computes the sum of all elements in an array by rows or by columns.

Paramètres:
  • n_columns – number of columns

  • values – all values in an array

  • by_rows – by rows or by columns

Renvoie:

sum of all elements

See vector_sum.cpp.

teachcompute.validation.cpu._validation.vector_sum_array_parallel(n_columns: int, values: numpy.ndarray[numpy.float32], by_rows: bool) float

Computes the sum of all elements in an array by rows or by columns. The computation is parallelized.

Paramètres:
  • n_columns – number of columns

  • values – all values in an array

  • by_rows – by rows or by columns

Renvoie:

sum of all elements

See vector_sum.cpp.

teachcompute.validation.cpu._validation.vector_sum_array_avx(n_columns: int, values: numpy.ndarray[numpy.float32]) float

Computes the sum of all elements in an array by rows or by columns. The computation uses AVX instructions (see AVX API).

Paramètres:
  • n_columns – number of columns

  • values – all values in an array

Renvoie:

sum of all elements

See vector_sum.cpp.

teachcompute.validation.cpu._validation.vector_sum_array_avx_parallel(n_columns: int, values: numpy.ndarray[numpy.float32]) float

Computes the sum of all elements in an array by rows or by columns. The computation uses AVX instructions and parallelization (see AVX API).

Paramètres:
  • n_columns – number of columns

  • values – all values in an array

Renvoie:

sum of all elements

See vector_sum.cpp.