2%> Return a MATLAB double, cell, or table matrix whose rows or
3%> columns are unrolled according to a prespecified ``weight``.
5%> \param[in] cmat : The input compact MATLAB double, cell, or table
6%> matrix that is to be unrolled along an axis.
7%> \param[in] dim : The input scalar MATLAB integer
8%> that can be either ``1`` or ``2``
9%> representing the axis along with the
10%> array must be unrolled.<br>
11%> An input value of ``1`` implies unrolling
12%> along the rows of the input ``cmat``,
13%> that is, unrolling the ``cmat`` columns.
14%> \param[in] weight : The input MATLAB matrix of integer values
15%> of size ``size(cmat, dim)`` containing the set
16%> of weights to used
for unrolling the input ``cmat``.
17%> \param[in] checked : The input scalar Python Boolean value.<br>
18%> If ``
true``, the condition ``~all(rem(weight, 1) == 0) || any(weight < 0)`` will be asserted.<br>
19%> This can be useful
for debugging, but can slow down the runtime performance.<br>
20%> (**optional**,
default = ``
false``)
23%> ``vmat`` : The output MATLAB matrix of the same type and kind
24%> as the input ``cmat``, containing the ``cmat`` that
25%> is unrolled along the specified axis ``dim``
using
26%> the input weights.<br>
31%> vmat = pm.array.verbose(cmat, dim, weight)
32%> vmat = pm.array.verbose(cmat, dim, weight, checked)
37%> Negative weights lead to a runtime error.<br>
38%> Any entry corresponding to a zero weight is ignored in the output ``vmat``.<br>
41%> \include{lineno} example/array/
verbose/main.m
43%> \include{lineno} example/array/
verbose/main.out.m
48%> \JoshuaOsborne, May 21 2024, 4:24 PM, University of Texas at Arlington<br>
49%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
50%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
51function vmat =
verbose(cmat, dim, weight, checked)
56 help(
"pm.array.verbose");
58 +
"At least three input arguments are required" + newline ...
59 +
"as described in the documentation above." + newline ...
64 if ~all(rem(weight, 1) == 0) || any(weight < 0)
69 + "The input ``weight`` argument displayed above" + newline ...
70 + "must be all non-negative whole-numbers." + newline ...
74 if ~any(dim == [1, 2])
79 + "The input ``dim`` argument displayed above" + newline ...
80 + "must be either 1 or 2." + newline ...
84 if length(weight) ~= size(cmat, dim)
87 + "The condition ``length(weight) == size(cmat, dim)``" + newline ...
88 + "must hold for the corresponding input arguments." + newline ...
90 + pm.io.
tab() + "length(weight) = " +
string(length(weight)) + newline ...
91 + pm.io.
tab() + "size(cmat,dim) = " +
string(size(cmat,dim)) + newline ...
96 cumsumwei = cumsum(weight);
97 sumwei = cumsumwei(end);
102 vmat = cell(sumwei, ncol);
103 elseif isa(cmat, "
double")
104 vmat = zeros(sumwei, ncol);
109 for ientry = 1 : nrow
110 iend = cumsumwei(ientry);
111 for iwei = istart : iend
112 vmat(iwei, :) = cmat(ientry, :);
118 vmat = cell(nrow, sumwei);
119 elseif isa(cmat, "
double")
120 vmat = zeros(nrow, sumwei);
125 for ientry = 1 : ncol
126 iend = cumsumwei(ientry);
127 for iwei = istart : iend
128 vmat(:, iwei) = cmat(:, ientry);
function tab()
Return a scalar MATLAB string containing 4 blank characters equivalent to a tab character.
function verbose(in cmat, in dim, in weight, in checked)
Return a MATLAB double, cell, or table matrix whose rows or columns are unrolled according to a presp...