/usr/share/octave/site/m/sundialsTB/nvector/N_VWrmsNorm.m is in octave-sundials 2.5.0-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function ret = N_VWrmsNorm(x,w,comm)
%N_VWrmsNorm returns the weighted root mean square norm of x
%with weight vector w:
% sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})/N]
%
% Usage: RET = N_VWrmsNorm ( X, W [, COMM] )
%
%If COMM is not present, N_VWrmsNorm returns the WRMS norm
%of the local portion of X. Otherwise, it returns the global
%WRMS norm..
% Radu Serban <radu@llnl.gov>
% Copyright (c) 2005, The Regents of the University of California.
% $Revision: 1.1 $Date: 2006/01/06 19:00:11 $
if nargin == 2
ret = dot(x.^2,w.^2);
ret = sqrt(ret/length(x));
else
lnrm = dot(x.^2,w.^2);
gnrm = 0.0;
MPI_Allreduce(lnrm,gnrm,'SUM',comm);
ln = length(x);
gn = 0;
MPI_Allreduce(ln,gn,'SUM',comm);
ret = sqrt(gnrm/gn);
end
|