## Copyright (C) 2011 		Hong Yu
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {} corr2cov (@var{sigma}, @var{corr})
## Returns the covariance value or matrix.
##
##
## Note that the rate @var{r} is specified as a fraction (i.e., 0.05,
## not 5 percent).
## @seealso{corrcoef, cov, cov2corr, ewstats, std}
## @end deftypefn

## Author: Hong Yu <hyu0401@hotmail.com>
## Description: Convert standard deviation and correlation to covariance

function ret = corr2cov (sigma, corr)

  if ( nargin != 2 )
    print_usage ();
  endif

  ret = corr;

  csize = size(corr);
  
  for i = 1:csize(1)
    for j = 1:csize(2)
      ret(i,j) *= sigma(i) * sigma(j);
    endfor
  endfor

endfunction

