|
Cytnx v0.9.3
|
Some basic algorithms API. More...
Functions | |
| Tensor | Sort (const Tensor &Tin) |
| sort Tensor along last axis. | |
| Tensor | Concatenate (Tensor T1, Tensor T2) |
| concatenate two 1d Tensor. | |
| Tensor | Vstack (const std::vector< Tensor > &In_tensors) |
| vertical stack a list of Tensor. | |
| Tensor | Hstack (const std::vector< Tensor > &In_tensors) |
| horizontal stack a list of Tensor. | |
| void | Vsplit_ (std::vector< Tensor > &out, const Tensor &Tin, const std::vector< cytnx_uint64 > &dims) |
| split a Matrix (a 2d Tensor) into a list of Matrices along the vertical direction. | |
| void | Hsplit_ (std::vector< Tensor > &out, const Tensor &Tin, const std::vector< cytnx_uint64 > &dims) |
| split a Matrix (a 2d Tensor) into a list of Matrices along the horizontal direction. | |
| std::vector< Tensor > | Vsplit (const Tensor &Tin, const std::vector< cytnx_uint64 > &dims) |
| split a Matrix (a 2d Tensor) into a list of Matrices along the vertical direction. | |
| std::vector< Tensor > | Hsplit (const Tensor &Tin, const std::vector< cytnx_uint64 > &dims) |
| split a Matrix (a 2d Tensor) into a list of Matrices along the horizontal direction. | |
Some basic algorithms API.
| std::vector< Tensor > cytnx::algo::Hsplit | ( | const Tensor & | Tin, |
| const std::vector< cytnx_uint64 > & | dims | ||
| ) |
split a Matrix (a 2d Tensor) into a list of Matrices along the horizontal direction.
This function will split a Matrix (a 2d Tensor) into a list of Matrices along the horizontal direction. That is, if the input Matrix Tin is:
\[ M = \begin{bmatrix} m_{11} & m_{12} & m_{13}\\ m_{21} & m_{22} & m_{23}\\ m_{31} & m_{32} & m_{33}\\ \end{bmatrix} \]
and the input dims is \( [2,1] \), the output will be \( [M_1, M_2] \), where:
\[ M_1 = \begin{bmatrix} m_{11} & m_{12}\\ m_{21} & m_{22}\\ m_{31} & m_{32}\\ \end{bmatrix} \]
and
\[ M_2 = \begin{bmatrix} m_{13}\\ m_{23}\\ m_{33}\\ \end{bmatrix} \]
| [in] | Tin | the input Matrix (a 2d Tensor). |
| [in] | dims | the column number of each Matrix in the output list. |
Tin with respect to dims. Tin need to be 2d Tensor (Matrix).dims cannot be empty.dims cannot be out of range. That is, the summation of dims need equal to the number of columns of Tin.dims cannot be zero. | void cytnx::algo::Hsplit_ | ( | std::vector< Tensor > & | out, |
| const Tensor & | Tin, | ||
| const std::vector< cytnx_uint64 > & | dims | ||
| ) |
split a Matrix (a 2d Tensor) into a list of Matrices along the horizontal direction.
This function is same as Hsplit, but the output is in the argument.
| [out] | out | a list of Tensor that will be the output. |
| [in] | Tin | the input Tensor. |
| [in] | dims | the column number of each Matrix in the output list. |
horizontal stack a list of Tensor.
This function will stack horizontally a list of Matrices (a 2d tensor) with same number of rows. That is, if the input Matrices are \( [M_1, M_2, M_3] \), the output will be:
\[ \begin{bmatrix} M_1, M_2, M_3 \end{bmatrix} \]
Note that the number of rows of \( M_1 \), \( M_2 \) and \( M_3 \) should be the same.
| [in] | In_tensors | a list of 2d Tensor (Matrix). |
In_tensors cannot be empty.In_tensors need to be 2d Tensor (Matrix).In_tensors should have same number of rows.In_tensors should be on same device.In_tensors cannot be Type.Bool or Type.Void. (see cytnx::Type) In_tensors are different, the data type of the output Tensor will be the stronger one. | std::vector< Tensor > cytnx::algo::Vsplit | ( | const Tensor & | Tin, |
| const std::vector< cytnx_uint64 > & | dims | ||
| ) |
split a Matrix (a 2d Tensor) into a list of Matrices along the vertical direction.
This function will split a Matrix (a 2d Tensor) into a list of Matrices along the vertical direction. That is, if the input Matrix Tin is:
\[ M = \begin{bmatrix} m_{11} & m_{12} & m_{13}\\ m_{21} & m_{22} & m_{23}\\ m_{31} & m_{32} & m_{33}\\ \end{bmatrix} \]
and the input dims is \( [1,2] \), the output will be \( [M_1, M_2] \), where:
\[ M_1 = \begin{bmatrix} m_{11} & m_{12} & m_{13}\\ \end{bmatrix} \]
and
\[ M_2 = \begin{bmatrix} m_{21} & m_{22} & m_{23}\\ m_{31} & m_{32} & m_{33}\\ \end{bmatrix} \]
| [in] | Tin | the input Matrix (a 2d Tensor). |
| [in] | dims | the row number of each Matrix in the output list. |
Tin with respect to dims. Tin need to be 2d Tensor (Matrix).dims cannot be empty.dims cannot be out of range. That is, the summation of dims need equal to the number of rows of Tin.dims cannot be zero. | void cytnx::algo::Vsplit_ | ( | std::vector< Tensor > & | out, |
| const Tensor & | Tin, | ||
| const std::vector< cytnx_uint64 > & | dims | ||
| ) |
split a Matrix (a 2d Tensor) into a list of Matrices along the vertical direction.
This function is same as Vsplit, but the output is in the argument.
| [out] | out | a list of Tensor that will be the output. |
| [in] | Tin | the input Tensor. |
| [in] | dims | the row number of each Matrix in the output list. |
vertical stack a list of Tensor.
This function will stack vertically a list of Matrices (a 2d tensor) with same number of columns. That is, if the input Matrices are \( [M_1, M_2, M_3] \), the output will be:
\[ \begin{bmatrix} M_1\\ M_2\\ M_3\\ \end{bmatrix} \]
Note that the number of columns of \( M_1 \), \( M_2 \) and \( M_3 \) should be the same.
| [in] | In_tensors | a list of 2d Tensor (Matrix). |
In_tensors cannot be empty.In_tensors need to be 2d Tensor (Matrix).In_tensors should have same number of columns.In_tensors should be on same device.In_tensors cannot be Type.Bool or Type.Void. (see cytnx::Type) In_tensors are different, the data type of the output Tensor will be the stronger one.