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 columns of the input ``cmat``,
13%> that is, unrolling the ``cmat`` rows.
14%> \param[in] weight : The input MATLAB matrix of integer values
15%> of size ``size(cmat, dim)`` containing the
16%> set of weights to used
for unrolling the
20%> ``vmat`` : The output MATLAB matrix of the same type and kind
21%> as the input ``cmat``, containing the ``cmat`` that
22%> is unrolled along the specified axis ``dim``
using
23%> the input weights.<br>
28%> vmat = pm.array.verbose(cmat, dim, weight)
33%> Negative weights lead to a runtime error.<br>
34%> Any entry corresponding to a zero weight is ignored in the output ``vmat``.<br>
37%> \include{lineno} example/array/
verbose/main.m
39%> \include{lineno} example/array/
verbose/main.out.m
44%> \JoshuaOsborne, May 21 2024, 4:24 PM, University of Texas at Arlington<br>
45%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
46%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
49 help(
"pm.array.verbose");
51 +
"At least three input arguments are required" + newline ...
52 +
"as described in the documentation above." + newline ...
56 if ~all(rem(weight, 1) == 0) || any(weight < 0)
61 + "The input ``weight`` argument displayed above" + newline ...
62 + "must be all non-ngavtive whole-numbers." + newline ...
66 if ~any(dim == [1, 2])
71 + "The input ``dim`` argument displayed above" + newline ...
72 + "must be either 1 or 2." + newline ...
76 if length(weight) ~= size(cmat, dim)
79 + "The condition ``length(weight) == size(cmat, dim)``" + newline ...
80 + "must hold for the corresponding input arguments." + newline ...
82 + pm.io.
tab() + "length(weight) = " +
string(length(weight)) + newline ...
83 + pm.io.
tab() + "size(cmat,dim) = " +
string(size(cmat,dim)) + newline ...
87 cumsumwei = cumsum(weight);
88 sumwei = cumsumwei(end);
93 vmat = cell(sumwei, ncol);
94 elseif isa(cmat, "
double")
95 vmat = zeros(sumwei, ncol);
100 for ientry = 1 : nrow
101 iend = cumsumwei(ientry);
102 for iwei = istart : iend
103 vmat(iwei, :) = cmat(ientry, :);
109 vmat = cell(nrow, sumwei);
110 elseif isa(cmat, "
double")
111 vmat = zeros(nrow, sumwei);
116 for ientry = 1 : ncol
117 iend = cumsumwei(ientry);
118 for iwei = istart : iend
119 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)
Return a MATLAB double, cell, or table matrix whose rows or columns are unrolled according to a presp...