【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.2.3.9.49 matrixbase::Padding
Contents
Description
Pad a matrix with selected way
Syntax
BOOL Padding( matrixbase & mPadding, int nPadSize, int nPaddingOption = MFILTER_ZEROPADDINGWINDOW )
Parameters
- mPadding
- [Modify] matrix with padded cells having same underlying base type of this matrix
- nPadSize
- [input] padding width, must be larger than 0
- nPaddingOption
- [input] Pads the area outside the borders in one of the following ways
- =MFILTER_ZEROPADDINGWINDOW -- Zero Pad, pads with zeroes
- =MFILTER_MAPPADDINGWINDOW -- Reflect Pad, values from immediate neighbors are repeated but more inside values are reflected padding more than 1 line;
- =MFILTER_REPEATEDGEPADDINGWINDOW--- repeat edge padding.
Return
Returns TRUE on success or FALSE on failure.
Examples
EX1
void matrixbase_Padding_ex1() { matrix<double> mat1 = { {1, 2, 3, 4}, {2, 4, 6, 8}, {5, 10, 15, 20} }; MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix Mat1(MatLy1); Mat1 = mat1; MatrixPage MatPg2; MatPg2.Create("Origin"); MatrixLayer MatLy2 = MatPg2.Layers(0); Matrix Mat2(MatLy2); int rc = Mat1.Padding( Mat2, 2 ); // default is MFILTER_ZEROPADDINGWINDOW if(!rc) printf("Error: Padding on a matrix failed. (Option:ZEROPADDINGWINDOW (default))\n"); else printf("Observe the padded matrix window %s from %s. (Option:ZEROPADDINGWINDOW (default))\n", Mat2.GetName(),Mat1.GetName()); MatrixPage MatPg3; MatPg3.Create("Origin"); MatrixLayer MatLy3 = MatPg3.Layers(0); Matrix Mat3(MatLy3); rc = Mat1.Padding( Mat3, 2, MFILTER_MAPPADDINGWINDOW ); if(!rc) printf("Error: Padding on a matrix failed. (Option:MAPPADDINGWINDOW)\n"); else printf("Observe the padded matrix window %s from %s. (Option:MAPPADDINGWINDOW)\n", Mat3.GetName(),Mat1.GetName()); MatrixPage MatPg4; MatPg4.Create("Origin"); MatrixLayer MatLy4 = MatPg4.Layers(0); Matrix Mat4(MatLy4); rc = Mat1.Padding( Mat4, 2, MFILTER_REPEATEDGEPADDINGWINDOW ); if(!rc) printf("Error: Padding on a matrix failed. (Option:REPEATEDGEPADDINGWINDOW)\n"); else printf("Observe the padded matrix window %s from %s. (Option:REPEATEDGEPADDINGWINDOW)\n", Mat4.GetName(),Mat1.GetName()); }
Remark
Pad a matrix with 0 or with adjacent cell values.
See Also
Header to Include
origin.h