ArrayDouble2D

class ArrayDouble2D(*args, **kwargs)

Bases: pybind11_object

Implementation of a generic 2D array used as base class for matrices and vectors.

This class implements a 2D array as a template class and all the basic functionalities common to matrices and vectors. More precisely:

  • concerning matrices, vpMatrix but also specific containers such as twist ( vpVelocityTwistMatrix and vpForceTwistMatrix ), homogeneous ( vpHomogeneousMatrix ), rotation ( vpRotationMatrix ) and homography ( vpHomography ) matrices inherit from vpArray2D<double> .

  • concerning vectors, vpColVector , vpRowVector but also specific containers describing the pose ( vpPoseVector ) and the rotation ( vpRotationVector ) inherit also from vpArray2D<double> .

The code below shows how to create a 2-by-3 array of doubles, set the element values and access them:

#include <visp3/code/vpArray2D.h

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpArray2D<float> a(2, 3);
  a[0][0] = -1; a[0][1] =  -2; a[0][2] = -3;
  a[1][0] =  4; a[1][1] = 5.5; a[1][2] =  6;

  std::cout << "a:" << std::endl;
  for (unsigned int i = 0; i < a.getRows(); ++i) {
    for (unsigned int j = 0; j < a.getCols(); ++j) {
      std::cout << a[i][j] << " ";
    }
    std::cout << std::endl;
  }
}

Once build, this previous code produces the following output:

a:
-1 -2 -3
4 5.5 6

If ViSP is build with c++11 enabled, you can do the same using:

#include <visp3/code/vpArray2D.h

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpArray2D<float> a{ {-1, -2, -3}, {4, 5.5, 6.0f} };
  std::cout << "a:\n" << a << std::endl;
}

The array could also be initialized using operator=(const std::initializer_list< std::initializer_list< Type > > &)

#include <visp3/code/vpArray2D.h

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpArray2D<float> a;
  a = { {-1, -2, -3}, {4, 5.5, 6.0f} };
}

You can also use reshape() function:

#include <visp3/code/vpArray2D.h

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpArray2D<float> a{ -1, -2, -3, 4, 5.5, 6.0f };
  a.reshape(2, 3);
}

Overloaded function.

  1. __init__(self: visp._visp.core.ArrayDouble2D) -> None

Basic constructor of a 2D array. Number of columns and rows are set to zero.

  1. __init__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> None

  2. __init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None

Constructor that initializes a 2D array with 0.

Parameters:
r

Array number of rows.

c

Array number of columns.

  1. __init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int, val: float) -> None

  2. __init__(self: visp._visp.core.ArrayDouble2D, vec: list[float], r: int = 0, c: int = 0) -> None

  3. __init__(self: visp._visp.core.ArrayDouble2D, list: std::initializer_list<double>) -> None

  4. __init__(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int, list: std::initializer_list<double>) -> None

  5. __init__(self: visp._visp.core.ArrayDouble2D, lists: std::initializer_list<std::initializer_list<double> >) -> None

  6. __init__(self: visp._visp.core.ArrayDouble2D, np_array: numpy.ndarray[numpy.float64]) -> None

Construct a 2D ViSP array by copying a 2D numpy array.

Parameters:
np_array

The numpy array to copy.

Methods

__init__

Overloaded function.

conv2

Overloaded function.

getCols

Return the number of columns of the 2D array.

getMaxValue

getMinValue

getRows

Return the number of rows of the 2D array.

hadamard

insert

Overloaded function.

insertStatic

numpy

Numpy view of the underlying array data.

reshape

resize

Set the size of the array and initialize all the values to zero.

save

Overloaded function.

saveYAML

size

Return the number of elements of the 2D array.

t

view

Overloaded function.

Inherited Methods

Operators

__doc__

__eq__

Overloaded function.

__getitem__

Overloaded function.

__hash__

__init__

Overloaded function.

__module__

__ne__

Overloaded function.

__repr__

__setitem__

Overloaded function.

Attributes

__annotations__

__hash__

__eq__(*args, **kwargs)

Overloaded function.

  1. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  2. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  3. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int]) -> float

  2. __getitem__(self: visp._visp.core.ArrayDouble2D, arg0: int) -> numpy.ndarray[numpy.float64]

  3. __getitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice) -> numpy.ndarray[numpy.float64]

  4. __getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple) -> numpy.ndarray[numpy.float64]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.core.ArrayDouble2D) -> None

Basic constructor of a 2D array. Number of columns and rows are set to zero.

  1. __init__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> None

  2. __init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None

Constructor that initializes a 2D array with 0.

Parameters:
r

Array number of rows.

c

Array number of columns.

  1. __init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int, val: float) -> None

  2. __init__(self: visp._visp.core.ArrayDouble2D, vec: list[float], r: int = 0, c: int = 0) -> None

  3. __init__(self: visp._visp.core.ArrayDouble2D, list: std::initializer_list<double>) -> None

  4. __init__(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int, list: std::initializer_list<double>) -> None

  5. __init__(self: visp._visp.core.ArrayDouble2D, lists: std::initializer_list<std::initializer_list<double> >) -> None

  6. __init__(self: visp._visp.core.ArrayDouble2D, np_array: numpy.ndarray[numpy.float64]) -> None

Construct a 2D ViSP array by copying a 2D numpy array.

Parameters:
np_array

The numpy array to copy.

__ne__(*args, **kwargs)

Overloaded function.

  1. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  2. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  3. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

__setitem__(*args, **kwargs)

Overloaded function.

  1. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int], arg1: float) -> None

  2. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: float) -> None

  3. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: float) -> None

  4. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[slice, slice], arg1: float) -> None

  5. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None

  6. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: numpy.ndarray[numpy.float64]) -> None

static conv2(*args, **kwargs)

Overloaded function.

  1. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D

  2. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None

  3. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D

  4. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None

getCols(self) int

Return the number of columns of the 2D array.

Note

See getRows() , size()

getMaxValue(self) float
getMinValue(self) float
getRows(self) int

Return the number of rows of the 2D array.

Note

See getCols() , size()

hadamard(self, m: visp._visp.core.ArrayDouble2D) visp._visp.core.ArrayDouble2D
insert(*args, **kwargs)

Overloaded function.

  1. insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None

  2. insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, r: int, c: int) -> visp._visp.core.ArrayDouble2D

static insertStatic(A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, C: visp._visp.core.ArrayDouble2D, r: int, c: int) None
numpy(self) numpy.ndarray[numpy.float64]

Numpy view of the underlying array data. This numpy view can be used to directly modify the array.

reshape(self, nrows: int, ncols: int) None
resize(self, nrows: int, ncols: int, flagNullify: bool = true, recopy_: bool = true) None

Set the size of the array and initialize all the values to zero.

Parameters:
nrows: int

number of rows.

ncols: int

number of column.

flagNullify: bool = true

if true, then the array is re-initialized to 0 after resize. If false, the initial values from the common part of the array (common part between old and new version of the array) are kept. Default value is true.

recopy_: bool = true

if true, will perform an explicit recopy of the old data.

static save(*args, **kwargs)

Overloaded function.

  1. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

  2. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

  3. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

static saveYAML(filename: str, A: visp._visp.core.ArrayDouble2D, header: str =) bool
size(self) int

Return the number of elements of the 2D array.

t(self) visp._visp.core.ArrayDouble2D
static view(*args, **kwargs)

Overloaded function.

  1. view(A: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D

  2. view(np_array: numpy.ndarray[numpy.float64]) -> visp._visp.core.ArrayDouble2D

Construct a 2D ViSP array that is a view of a numpy array. When it is modified, the numpy array is also modified. It cannot be resized.

Parameters:
np_array

The numpy array to copy.

__hash__ = None