Scale a matrix by rows or columns, or a multidimensional tensor along a specified dimension. If a is a vector of length
rows (
b)
, returndiag (
a) *
b (but computed much more efficiently). Similarly, if b is a vector of lengthcolumns(
a)
, return a* diag(
b)
.If b is a multidimensional array and a a vector, c will have the same shape as b, with C
(i,:,...) =
a(i)*
b(i,:,...)
.If a is a multidimensional array and b a vector, c will have the same shape as a, with C
(:,...,i) =
a(:,...,i)*
b(i)
.If ind is supplied, a should be an array and b a vector of length
size (
a,index)
. The result is then C(:,...,i,:,...) =
a(:,...,i,:,...)*
b(i)
where i indexes the ind-th dimension.