SubRowVector¶
- class SubRowVector(*args, **kwargs)¶
Bases:
RowVector
This class provides a mask on a vpRowVector . It has internally a pointer to the parent vpRowVector . All properties of vpRowVector are available with a vpSubRowVector .
Note
See vpMatrix vpColVector vpRowVector
Overloaded function.
__init__(self: visp._visp.core.SubRowVector) -> None
Default constructor that creates an empty vector.
__init__(self: visp._visp.core.SubRowVector, v: visp._visp.core.RowVector, offset: int, ncols: int) -> None
Construct a sub-row vector from a parent row vector.
- Parameters:
- v
parent row vector.
- offset
offset where the sub-row vector starts in the parent row vector.
- ncols
size of the sub-row vector.
Methods
Overloaded function.
This method can be used to detect if the parent row vector always exits or its size have not changed.
Overloaded function.
Inherited Methods
Return the array max value.
Convert a column vector containing angles in degrees into radians.
Extract a sub-row vector from a row vector.
Removes all elements from the vector (which are destroyed), leaving the container with a size of 0.
Overloaded function.
- return:
The corresponding std::vector<double>.
Return the sum square of all the elements \(v_{i}\) of the row vector v(n).
Return the number of rows of the 2D array.
Overloaded function.
Overloaded function.
Overloaded function.
Numpy view of the underlying array data.
Returns a C++ code representation of this data array (see cppPrint in the C++ documentation)
Compute the median value of all the elements of the vector.
Return the number of columns of the 2D array.
Overloaded function.
Pretty print a row vector.
Overloaded function.
Overloaded function.
Compute and return the Frobenius norm \(||v|| = \sqrt{ \sum{v_{i}^2}}\) .
Overloaded function.
Overloaded function.
Insert array B in array A at the given position.
Returns the CSV representation of this data array (see csvPrint in the C++ documentation)
Save an array in a YAML-formatted file.
Returns the CSV representation of this data array (see maplePrint in the C++ documentation)
Compute the standard deviation value of all the elements of the vector.
Overloaded function.
Overloaded function.
Compute the mean value of all the elements of the vector.
Return the array min value.
Return the sum of all the elements \(v_{i}\) of the row vector v(n).
Returns the Matlab representation of this data array (see matlabPrint in the C++ documentation)
Return the number of elements of the 2D array.
Convert a column vector containing angles in radians into degrees.
Operators
__doc__
Overloaded function.
__module__
Attributes
__annotations__
- __add__(self, v: visp._visp.core.RowVector) visp._visp.core.RowVector ¶
Operator that allows to add to row vectors that have the same size.
- __eq__(self, v: visp._visp.core.RowVector) bool ¶
Comparison operator.
- __getitem__(*args, **kwargs)¶
Overloaded function.
__getitem__(self: visp._visp.core.RowVector, arg0: int) -> float
__getitem__(self: visp._visp.core.RowVector, arg0: slice) -> numpy.ndarray[numpy.float64]
- __iadd__(self, v: visp._visp.core.RowVector) visp._visp.core.RowVector ¶
Operator that allows to add two row vectors that have the same size.
- __imul__(self, x: float) visp._visp.core.RowVector ¶
Operator that allows to multiply each element of a row vector by a scalar.
vpRowVector v(3); v[0] = 1; v[1] = 2; v[2] = 3; v *= 3; // v is now equal to : [3 6 9]
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.SubRowVector) -> None
Default constructor that creates an empty vector.
__init__(self: visp._visp.core.SubRowVector, v: visp._visp.core.RowVector, offset: int, ncols: int) -> None
Construct a sub-row vector from a parent row vector.
- Parameters:
- v
parent row vector.
- offset
offset where the sub-row vector starts in the parent row vector.
- ncols
size of the sub-row vector.
- __isub__(self, v: visp._visp.core.RowVector) visp._visp.core.RowVector ¶
Operator that allows to subtract two row vectors that have the same size.
- __itruediv__(self, x: float) visp._visp.core.RowVector ¶
Operator that allows to divide each element of a row vector by a scalar.
vpRowVector v(3); v[0] = 8; v[1] = 4; v[2] = 2; // v is equal to : [8 4 2] v /= 2; // v is equal to : [4 2 1]
- __mul__(*args, **kwargs)¶
Overloaded function.
__mul__(self: visp._visp.core.RowVector, x: visp._visp.core.ColVector) -> float
Multiply a row vector by a column vector.
- Parameters:
- x
Column vector.
- Returns:
A scalar.
__mul__(self: visp._visp.core.RowVector, M: visp._visp.core.Matrix) -> visp._visp.core.RowVector
Multiply a row vector by a matrix.
- Parameters:
- M
Matrix.
- Returns:
The resulting row vector.
__mul__(self: visp._visp.core.RowVector, x: float) -> visp._visp.core.RowVector
Operator that allows to multiply each element of a row vector by a scalar.
vpRowVector v(3); v[0] = 1; v[1] = 2; v[2] = 3; vpRowVector w = v * 3; // v is unchanged // w is now equal to : [3 6 9]
- Parameters:
- x
The scalar.
- Returns:
The row vector multiplied by the scalar. The current row vector (*this) is unchanged.
- __ne__(self, v: visp._visp.core.RowVector) bool ¶
- __neg__(self) visp._visp.core.RowVector ¶
Operator that allows to negate all the row vector elements.
vpRowVector r(3, 1); // r contains [1 1 1] vpRowVector v = -r; // v contains [-1 -1 -1]
- __sub__(self, v: visp._visp.core.RowVector) visp._visp.core.RowVector ¶
Operator that allows to subtract to row vectors that have the same size.
- __truediv__(self, x: float) visp._visp.core.RowVector ¶
Operator that allows to divide each element of a row vector by a scalar.
vpRowVector v(3); v[0] = 8; v[1] = 4; v[2] = 2; vpRowVector w = v / 2; // v is equal to : [8 4 2] // w is equal to : [4 2 1]
- checkParentStatus(self) None ¶
This method can be used to detect if the parent row vector always exits or its size have not changed. If this not the case an exception is thrown.
- clear(self) None ¶
Removes all elements from the vector (which are destroyed), leaving the container with a size of 0.
- static conv2(*args, **kwargs)¶
Overloaded function.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb6a440>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First matrix.
- kernel
Second matrix.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb8c0a0>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First array.
- kernel
Second array.
- res
Result.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb6a440>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First matrix.
- kernel
Second matrix.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb8c0a0>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First array.
- kernel
Second array.
- res
Result.
- mode
Convolution mode: “full” (default), “same”, “valid”.
- deg2rad(self) None ¶
Convert a column vector containing angles in degrees into radians.
Note
See rad2deg()
- extract(self, c: int, rowsize: int) visp._visp.core.RowVector ¶
Extract a sub-row vector from a row vector.
vpRowVector r1; for (unsigned int i=0; i<4; ++i) r1.stack(i); // r1 is equal to [0 1 2 3] vpRowVector r2 = r1.extract(1, 3); // r2 is equal to [1 2 3]
- frobeniusNorm(self) float ¶
Compute and return the Frobenius norm \(||v|| = \sqrt{ \sum{v_{i}^2}}\) .
- Returns:
The Frobenius norm if the vector is initialized, 0 otherwise.
- hadamard(*args, **kwargs)¶
Overloaded function.
hadamard(self: visp._visp.core.RowVector, v: visp._visp.core.RowVector) -> visp._visp.core.RowVector
Compute the Hadamard product (element wise vector multiplication).
- Parameters:
- v
Second vector;
- Returns:
v1.hadamard(v2) The kronecker product : \(v1 \circ v2 = (v1 \circ v2)_{i} = (v1)_{i} (v2)_{i}\)
hadamard(self: visp._visp.core.ArrayDouble2D, m: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
- Parameters:
- m
Second matrix;
- Returns:
m1.hadamard(m2) The Hadamard product : \(m1 \circ m2 = (m1 \circ m2)_{i,j} = (m1)_{i,j} (m2)_{i,j}\)
- init(*args, **kwargs)¶
Overloaded function.
init(self: visp._visp.core.SubRowVector, v: visp._visp.core.RowVector, offset: int, ncols: int) -> None
Initialize a sub-row vector from a parent row vector.
- Parameters:
- v
parent row vector.
- offset
offset where the sub-row vector starts in the parent row vector.
- ncols
size of the sub-row vector.
init(self: visp._visp.core.RowVector, v: visp._visp.core.RowVector, c: int, ncols: int) -> None
Initialize the row vector from a part of an input row vector v .
The sub-vector starting from v[c] element and ending on v[c+ncols-1] element is used to initialize the constructed row vector.
The following code shows how to use this function:
#include <visp3/core/vpRowVector.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpRowVector v(4); int val = 0; for(size_t i=0; i<v.getCols(); i++) { v[i] = val++; } std::cout << "v: " << v << std::endl; vpRowVector w; w.init(v, 1, 2); std::cout << "w: " << w << std::endl; }
It produces the following output:
v: 0 1 2 3 w: 1 2
- Parameters:
- v
Input row vector used for initialization.
- c
column index in v that corresponds to the first element of the row vector to construct.
- ncols
Number of columns of the constructed row vector.
- insert(*args, **kwargs)¶
Overloaded function.
insert(self: visp._visp.core.RowVector, i: int, v: visp._visp.core.RowVector) -> None
Insert a row vector.The following example shows how to use this function:
#include <visp3/core/vpRowVector.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpRowVector v(4); for (unsigned int i=0; i < v.size(); i++) v[i] = i; std::cout << "v: " << v << std::endl; vpRowVector w(2); for (unsigned int i=0; i < w.size(); i++) w[i] = i+10; std::cout << "w: " << w << std::endl; v.insert(1, w); std::cout << "v: " << v << std::endl; }
It produces the following output:
v: 0 1 2 3 w: 10 11 v: 0 10 11 3
- Parameters:
- i
Index of the first element to introduce. This index starts from 0.
- v
Row vector to insert.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None
Insert array A at the given position in the current array.
Warning
Throw vpException::dimensionError if the dimensions of the matrices do not allow the operation.
- Parameters:
- A
The array to insert.
- r
The index of the row to begin to insert data.
- c
The index of the column to begin to insert data.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, r: int, c: int) -> visp._visp.core.ArrayDouble2D
Insert array B in array A at the given position.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.
- Parameters:
- A
Main array.
- B
Array to insert.
- r
Index of the row where to add the array.
- c
Index of the column where to add the array.
- Returns:
Array with B insert in A.
- static insertStatic(A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, C: visp._visp.core.ArrayDouble2D, r: int, c: int) None ¶
Insert array B in array A at the given position.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.
- Parameters:
- A: visp._visp.core.ArrayDouble2D¶
Main array.
- B: visp._visp.core.ArrayDouble2D¶
Array to insert.
- C: visp._visp.core.ArrayDouble2D¶
Result array.
- r: int¶
Index of the row where to insert array B.
- c: int¶
Index of the column where to insert array B.
- static mean(v: visp._visp.core.RowVector) float ¶
Compute the mean value of all the elements of the vector.
- static median(v: visp._visp.core.RowVector) float ¶
Compute the median value of all the elements of the vector.
- normalize(*args, **kwargs)¶
Overloaded function.
normalize(self: visp._visp.core.RowVector) -> visp._visp.core.RowVector
Normalise the vector modifying the vector as:
\[{\bf x} = \frac{{\bf x}}{\sqrt{\sum_{i=1}^{n}x^2_i}} \]where \(x_i\) is an element of the row vector \(\bf x\) .
normalize(self: visp._visp.core.RowVector, x: visp._visp.core.RowVector) -> visp._visp.core.RowVector
Normalize the vector given as input parameter and return the normalized vector:
\[{\bf x} = \frac{{\bf x}}{\sqrt{\sum_{i=1}^{n}x^2_i}} \]where \(x_i\) is an element of the row vector \(\bf x\) .
- numpy(self) numpy.ndarray[numpy.float64] ¶
Numpy view of the underlying array data. This numpy view can be used to directly modify the array.
- print(self: visp._visp.core.RowVector, s: std::ostream, length: int, intro: str = 0) int ¶
Pretty print a row vector. The data are tabulated. The common widths before and after the decimal point are set with respect to the parameter maxlen.
Note
See std::ostream & operator<<(std::ostream &s, const vpArray2D<Type> &A)
- Parameters:
- s
Stream used for the printing.
- length
The suggested width of each row vector element. The actual width grows in order to accommodate the whole integral part, and shrinks if the whole extent is not needed for all the numbers.
- intro
The introduction which is printed before the vector. Can be set to zero (or omitted), in which case the introduction is not printed.
- Returns:
Returns the common total width for all vector elements.
- rad2deg(self) None ¶
Convert a column vector containing angles in radians into degrees.
Note
See deg2rad()
- reshape(*args, **kwargs)¶
Overloaded function.
reshape(self: visp._visp.core.RowVector, M: visp._visp.core.Matrix, nrows: int, ncols: int) -> None
Reshape the row vector in a matrix.The following example shows how to use this method.
#include <visp3/core/vpRowVector.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { int var=0; vpMatrix mat(3, 4); for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) mat[i][j] = ++var; std::cout << "mat: \n" << mat << std::endl; vpRowVector row = mat.stackRows(); std::cout << "row vector: " << row << std::endl; vpMatrix remat = row.reshape(3, 4); std::cout << "remat: \n" << remat << std::endl; }
If you run the previous example, you get:
mat: 1 2 3 4 5 6 7 8 9 10 11 12 row vector: 1 2 3 4 5 6 7 8 9 10 11 12 remat: 1 2 3 4 5 6 7 8 9 10 11 12
- Parameters:
- M
the reshaped matrix.
- nrows
number of rows of the matrix.
- ncols
number of columns of the matrix.
reshape(self: visp._visp.core.RowVector, nrows: int, ncols: int) -> visp._visp.core.Matrix
Note
See reshape(vpMatrix &, const unsigned int &, const unsigned int &)
- Parameters:
- nrows
number of rows of the matrix.
- ncols
number of columns of the matrix.
- Returns:
The resulting matrix.
reshape(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int) -> None
- resize(*args, **kwargs)¶
Overloaded function.
resize(self: visp._visp.core.RowVector, i: int, flagNullify: bool = true) -> None
Modify the size of the row vector.
- Parameters:
- i
Size of the vector. This value corresponds to the vector number of columns.
- flagNullify
If true, set the data to zero.
resize(self: visp._visp.core.RowVector, nrows: int, ncols: int, flagNullify: bool) -> None
Resize the row vector to a ncols-dimension vector. This function can only be used with nrows = 1.
- Parameters:
- nrows
Vector number of rows. This value should be set to 1.
- ncols
Vector number of columns. This value corresponds to the size of the vector.
- flagNullify
If true, set the data to zero.
resize(self: visp._visp.core.ArrayDouble2D, 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
number of rows.
- ncols
number of column.
- flagNullify
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_
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 a matrix to a file.
Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.
Note
See load()
- Parameters:
- filename
Absolute file name.
- A
Array to be saved.
- binary
If true the matrix is saved in a binary file, else a text file.
- header
Optional line that will be saved at the beginning of the file.
- Returns:
Returns true if success.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
Save a matrix to a file.
Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.
Note
See load()
- Parameters:
- filename
Absolute file name.
- A
Array to be saved.
- binary
If true the matrix is saved in a binary file, else a text file.
- header
Optional line that will be saved at the beginning of the file.
- Returns:
Returns true if success.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
Save a matrix to a file.
Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.
Note
See load()
- Parameters:
- filename
Absolute file name.
- A
Array to be saved.
- binary
If true the matrix is saved in a binary file, else a text file.
- header
Optional line that will be saved at the beginning of the file.
- Returns:
Returns true if success.
- static saveYAML(filename: str, A: visp._visp.core.ArrayDouble2D, header: str =) bool ¶
Save an array in a YAML-formatted file.
Here is an example of outputs.
vpArray2D<double> M(3,4); vpArray2D::saveYAML("matrix.yml", M, "example: a YAML-formatted header"); vpArray2D::saveYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted \ header\n - with inner indentation");
Content of matrix.yml:
example: a YAML-formatted header rows: 3 cols: 4 data: - [0, 0, 0, 0] - [0, 0, 0, 0] - [0, 0, 0, 0]
Content of matrixIndent.yml:
example: - a YAML-formatted header - with inner indentation rows: 3 cols: 4 data: - [0, 0, 0, 0] - [0, 0, 0, 0] - [0, 0, 0, 0]
Note
See loadYAML()
- Parameters:
- filename
absolute file name.
- A
array to be saved in the file.
- header
optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any.
- Returns:
Returns true if success.
- stack(*args, **kwargs)¶
Overloaded function.
stack(self: visp._visp.core.RowVector, d: float) -> None
Stack row vector with a new element at the end of the vector.
vpRowVector v(3, 1); // v is equal to [1 1 1] v.stack(-2); // v is equal to [1 1 1 -2]
Note
See stack(const vpRowVector &, const vpRowVector &)
Note
See stack(const vpRowVector &, const vpRowVector &, vpRowVector &)
- Parameters:
- d
Element to stack to the existing one.
stack(self: visp._visp.core.RowVector, v: visp._visp.core.RowVector) -> None
Stack row vectors.
vpRowVector v1(3, 1); // v1 is equal to [1 1 1] vpRowVector v2(2, 3); // v2 is equal to [3 3] v1.stack(v2); // v1 is equal to [1 1 1 3 3]
Note
See stack(const vpRowVector &, const double &)
Note
See stack(const vpRowVector &, const vpRowVector &)
Note
See stack(const vpRowVector &, const vpRowVector &, vpRowVector &)
- Parameters:
- v
Vector to stack to the existing one.
- static stackVectors(*args, **kwargs)¶
Overloaded function.
stackVectors(A: visp._visp.core.RowVector, B: visp._visp.core.RowVector) -> visp._visp.core.RowVector
Stack row vectors.
vpRowVector r1(3, 1); // r1 is equal to [1 1 1] vpRowVector r2(2, 3); // r2 is equal to [3 3] vpRowVector v; v = vpRowVector::stack(r1, r2); // v is equal to [1 1 1 3 3]
Note
See stack(const vpRowVector &)
Note
See stack(const vpRowVector &, const vpRowVector &, vpRowVector &)
- Parameters:
- A
Initial vector.
- B
Vector to stack at the end of A.
- Returns:
Stacked vector \([A B]\) .
stackVectors(A: visp._visp.core.RowVector, B: visp._visp.core.RowVector, C: visp._visp.core.RowVector) -> None
Stack row vectors.
vpRowVector r1(3, 1); // r1 is equal to [1 1 1] vpRowVector r2(2, 3); // r2 is equal to [3 3] vpRowVector v; vpRowVector::stack(r1, r2, v); // v is equal to [1 1 1 3 3]
Note
See stack(const vpRowVector &)
Note
See stack(const vpRowVector &, const vpRowVector &)
- Parameters:
- A
Initial vector.
- B
Vector to stack at the end of A.
- C
Resulting stacked vector \(C = [A B]\) .
- static stdev(v: visp._visp.core.RowVector, useBesselCorrection: bool = false) float ¶
Compute the standard deviation value of all the elements of the vector.
- strCppCode(self, name: str, byte_per_byte: bool = False) str ¶
Returns a C++ code representation of this data array (see cppPrint in the C++ documentation)
- strCsv(self) str ¶
Returns the CSV representation of this data array (see csvPrint in the C++ documentation)
- strMaple(self) str ¶
Returns the CSV representation of this data array (see maplePrint in the C++ documentation)
- strMatlab(self) str ¶
Returns the Matlab representation of this data array (see matlabPrint in the C++ documentation)
- sum(self) float ¶
Return the sum of all the elements \(v_{i}\) of the row vector v(n).
- Returns:
The sum square value: \(\sum_{j=0}^{n} v_j\) .
- sumSquare(self) float ¶
Return the sum square of all the elements \(v_{i}\) of the row vector v(n).
- Returns:
The sum square value: \(\sum_{j=0}^{n} v_j^{2}\) .
- t(*args, **kwargs)¶
Overloaded function.
t(self: visp._visp.core.RowVector) -> visp._visp.core.ColVector
Transpose the row vector. The resulting vector becomes a column vector.
t(self: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
Compute the transpose of the array.
- Returns:
vpArray2D<Type> C = A^T
- transpose(*args, **kwargs)¶
Overloaded function.
transpose(self: visp._visp.core.RowVector) -> visp._visp.core.ColVector
Transpose the row vector. The resulting vector becomes a column vector.
Note
See t()
transpose(self: visp._visp.core.RowVector, v: visp._visp.core.ColVector) -> None
Transpose the row vector. The resulting vector v becomes a column vector.
Note
See t()
-
__hash__ =
None
¶