/*---------------------------------------------------------------------------* * IT++ * *---------------------------------------------------------------------------* * Copyright (c) 1995-2004 by Tony Ottosson, Thomas Eriksson, Pål Frenger, * * Tobias Ringström, and Johan Bergman. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation under the terms of the GNU General Public License is hereby * * granted. No representations are made about the suitability of this * * software for any purpose. It is provided "as is" without expressed or * * implied warranty. See the GNU General Public License for more details. * *---------------------------------------------------------------------------*/ /*! \file \brief Functions and classes for calculation of statistics \author Tony Ottosson and Johan Bergman 1.5 2004/10/01 07:15:23 */ #include "base/stat.h" #include "base/itassert.h" #include "base/svd.h" #include "base/elmatfunc.h" #include "base/matfunc.h" namespace itpp { double mean(const vec &v) { return sum(v)/v.length(); } complex mean(const cvec &v) { return sum(v)/double(v.size()); } double mean(const svec &v) { return (double)sum(v)/v.length(); } double mean(const ivec &v) { return (double)sum(v)/v.length(); } double mean(const mat &m) { return sum(sum(m))/(m.rows()*m.cols()); } complex mean(const cmat &m) { return sum(sum(m))/static_cast >(m.rows()*m.cols()); } double mean(const smat &m) { return static_cast(sum(sum(m)))/(m.rows()*m.cols()); } double mean(const imat &m) { return static_cast(sum(sum(m)))/(m.rows()*m.cols()); } double norm(const cvec &v) { int i; double E=0.0; for (i=0; i sum=0.0; const complex *p=v._data(); for (int i=0; i