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.
__init__(self: visp._visp.core.ArrayDouble2D) -> None
Basic constructor of a 2D array. Number of columns and rows are set to zero.
__init__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> None
__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.
__init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int, val: float) -> None
__init__(self: visp._visp.core.ArrayDouble2D, vec: list[float], r: int = 0, c: int = 0) -> None
__init__(self: visp._visp.core.ArrayDouble2D, list: std::initializer_list<double>) -> None
__init__(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int, list: std::initializer_list<double>) -> None
__init__(self: visp._visp.core.ArrayDouble2D, lists: std::initializer_list<std::initializer_list<double> >) -> None
__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
Overloaded function.
Overloaded function.
Return the number of columns of the 2D array.
Return the number of rows of the 2D array.
Overloaded function.
Numpy view of the underlying array data.
Set the size of the array and initialize all the values to zero.
Overloaded function.
Return the number of elements of the 2D array.
Overloaded function.
Inherited Methods
Operators
__doc__
Overloaded function.
Overloaded function.
Overloaded function.
__module__
Overloaded function.
__repr__
Overloaded function.
Attributes
__annotations__
- __eq__(*args, **kwargs)¶
Overloaded function.
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
- __getitem__(*args, **kwargs)¶
Overloaded function.
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int]) -> float
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: int) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple) -> numpy.ndarray[numpy.float64]
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.ArrayDouble2D) -> None
Basic constructor of a 2D array. Number of columns and rows are set to zero.
__init__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> None
__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.
__init__(self: visp._visp.core.ArrayDouble2D, r: int, c: int, val: float) -> None
__init__(self: visp._visp.core.ArrayDouble2D, vec: list[float], r: int = 0, c: int = 0) -> None
__init__(self: visp._visp.core.ArrayDouble2D, list: std::initializer_list<double>) -> None
__init__(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int, list: std::initializer_list<double>) -> None
__init__(self: visp._visp.core.ArrayDouble2D, lists: std::initializer_list<std::initializer_list<double> >) -> None
__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.
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
- __setitem__(*args, **kwargs)¶
Overloaded function.
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int], arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[slice, slice], arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: numpy.ndarray[numpy.float64]) -> None
- static conv2(*args, **kwargs)¶
Overloaded function.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
- hadamard(self, m: visp._visp.core.ArrayDouble2D) visp._visp.core.ArrayDouble2D ¶
- insert(*args, **kwargs)¶
Overloaded function.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None
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.
- 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.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
- t(self) visp._visp.core.ArrayDouble2D ¶
- static view(*args, **kwargs)¶
Overloaded function.
view(A: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
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
¶