# v_pow2cep

## PURPOSE

V_POW2CEP convert power domain means and variances to the cepstral domain

## SYNOPSIS

function [u,v]=v_pow2cep(m,c,mode)

## DESCRIPTION

    V_POW2CEP convert power domain means and variances to the cepstral domain
     Inputs:
        m: vector giving means in the power domain
        c: covariance matrix in the power domain (or diag(c) if diagonal)
     mode: 'c'  pow=exp(v_irdct(cep))   [default]
           'f'  pow=exp(v_rsfft(cep)/n)  [fft length even]
           'fo' pow=exp(v_rsfft(cep)/n)  [fft length odd]
           'i'  pow=exp(cep)           [ no transformation ]

     Outputs:
        u: row vector giving the cepstral means with u(1) the 0'th cepstral coefficient
        v: cepstral covariance matrix

## CROSS-REFERENCE INFORMATION

This function calls:

- v_rdct V_RDCT Discrete cosine transform of real data Y=(X,N,A,B)
- v_rsfft V_RSFFT fft of a real symmetric spectrum X=(Y,N)

This function is called by:

- v_lognmpdf V_LOGNMPDF calculate pdf of a multivariate lognormal distribution P=(X,M,V)

## SOURCE CODE

    0001 function [u,v]=v_pow2cep(m,c,mode)
    0002 %V_POW2CEP convert power domain means and variances to the cepstral domain
    0003 % Inputs:
    0004 %    m: vector giving means in the power domain
    0005 %    c: covariance matrix in the power domain (or diag(c) if diagonal)
    0006 % mode: 'c'  pow=exp(v_irdct(cep))   [default]
    0007 %       'f'  pow=exp(v_rsfft(cep)/n)  [fft length even]
    0008 %       'fo' pow=exp(v_rsfft(cep)/n)  [fft length odd]
    0009 %       'i'  pow=exp(cep)           [ no transformation ]
    0010 %
    0011 % Outputs:
    0012 %    u: row vector giving the cepstral means with u(1) the 0'th cepstral coefficient
    0013 %    v: cepstral covariance matrix
    0014
    0015 %      Copyright (C) Mike Brookes 1998
    0016 %      Version: $Id: v_pow2cep.m 10865 2018-09-21 17:22:45Z dmb $
    0017 %
    0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0019 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0020 %
    0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0022 %   This program is free software; you can redistribute it and/or modify
    0023 %   it under the terms of the GNU Lesser General Public License as published by
    0024 %   the Free Software Foundation; either version 3 of the License, or
    0025 %   (at your option) any later version.
    0026 %
    0027 %   This program is distributed in the hope that it will be useful,
    0028 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0030 %   GNU Lesser General Public License for more details.
    0031 %
    0032 %   You can obtain a copy of the GNU Lesser General Public License from
    0033 %   https://www.gnu.org/licenses/ .
    0034 %
    0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0036
    0037 if nargin<3 mode='c'; end
    0038 if min(size(c))==1
    0039    c=diag(c);
    0040 end
    0041 m=m(:)';        % force to be a row vector
    0042 q=log(1+c./(m'*m));
    0043 p=log(m)-0.5*diag(q)';
    0044 if any(mode=='f')
    0045    n=2*length(m)-2;
    0046    if any(mode=='o')
    0047       n=n+1;
    0048    end
    0049    u=v_rsfft(p,n);
    0050    v=rsfft(rsfft(q,n)',n);
    0051 elseif any(mode=='i')
    0052     u=p;
    0053     v=q;
    0054 else
    0055    u=v_rdct(p);
    0056    v=rdct(rdct(q)');
    0057 end