-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpstimes.m
More file actions
executable file
·41 lines (40 loc) · 1.3 KB
/
Copy pathpstimes.m
File metadata and controls
executable file
·41 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [mat] = pstimes(mat, scalar)
%% Licensing
%
% License: BSD License
% cane Multiphysics default license: cane/license.txt
%
% Main authors: Andreas Apostolatos
%
%% Function documentation
%
% Performs pagewise computation of matrix times scalar.
%
% Input :
% mat : The 3-d array of first operand matrices. The size( mat1 )
% should be [nMat, m, n], where nMat is the number of matrices to
% multiply and m, n are the dimensions of each matrix. There is
% no restriction on m and n
% scalar : The array of scalars. The size( scalar ) should be [nMat, 1].
%
% (the number of entries in the first dimension has to be equal
% for both input parameters)
%
% Output :
% mat : The pagewise product of each matrix in mat with the corresponding
% scalar in scalar. The size of the result is the same as the size
% of the input matrix
%
%% Function main body
scalarSize = size(scalar);
if length(scalarSize) > 2 || prod(scalarSize) == 0
error('page-wise scalar multiplication: error in scalar input dimensions!\n')
end
if( scalarSize(2) > 1 )
if( scalarSize(1) > 1 )
error('page-wise multiplication: error in scalar input dimensions!\n')
end
scalar = scalar';
end
mat = bsxfun(@times,mat,scalar);
end