/* CVM Class Library */
/* Copyright (C), Sergei Nikolaev, 1992-2005, http://cvmlib.com */

#include "StdAfx.h"
#include "cvm.h"
#include "blas.h"

#if defined (_MSC_VER)
#   pragma warning(disable:4786)
#endif

CVM_NAMESPACE_BEG

template<>
CVM_API void
__gemm<std::complex<float>, basic_cmatrix<float, std::complex<float> > >
    (const basic_cmatrix<float, std::complex<float> >& ml, bool bTrans1,
     const basic_cmatrix<float, std::complex<float> >& mr, bool bTrans2,
     std::complex<float> dAlpha, 
     basic_cmatrix<float, std::complex<float> >& mRes, 
     std::complex<float> dBeta)
{
#if defined (_MSC_VER)
    CGEMM (bTrans1 ? gC<float>().pC() : gC<float>().pN(), 1, bTrans2 ? gC<float>().pC() : gC<float>().pN(), 1,
#else
    CGEMM (bTrans1 ? gC<float>().pC() : gC<float>().pN(),    bTrans2 ? gC<float>().pC() : gC<float>().pN(),
#endif
           bTrans1 ? ml._pn() : ml._pm(),
           bTrans2 ? mr._pm() : mr._pn(),
           bTrans1 ? ml._pm() : ml._pn(),
           &dAlpha,
           ml._pd(), ml._pldm(),
           mr._pd(), mr._pldm(),
           &dBeta,
           mRes, mRes._pld());
}

template<>
CVM_API void
__gemm<std::complex<double>, basic_cmatrix<double, std::complex<double> > >
    (const basic_cmatrix<double, std::complex<double> >& ml, bool bTrans1,
     const basic_cmatrix<double, std::complex<double> >& mr, bool bTrans2,
     std::complex<double> dAlpha,
     basic_cmatrix<double, std::complex<double> >& mRes,
     std::complex<double> dBeta)
{
#if defined (_MSC_VER)
    ZGEMM (bTrans1 ? gC<double>().pC() : gC<double>().pN(), 1, bTrans2 ? gC<double>().pC() : gC<double>().pN(), 1,
#else
    ZGEMM (bTrans1 ? gC<double>().pC() : gC<double>().pN(),    bTrans2 ? gC<double>().pC() : gC<double>().pN(),
#endif
           bTrans1 ? ml._pn() : ml._pm(),
           bTrans2 ? mr._pm() : mr._pn(),
           bTrans1 ? ml._pm() : ml._pn(),
           &dAlpha,
           ml._pd(), ml._pldm(),
           mr._pd(), mr._pldm(),
           &dBeta,
           mRes, mRes._pld());
}

template<>
CVM_API void
__hemm<std::complex<float>, basic_schmatrix<float, std::complex<float> >, basic_cmatrix<float, std::complex<float> > >
    (bool bLeft,
     const basic_schmatrix<float, std::complex<float> >& ml,
     const basic_cmatrix<float, std::complex<float> >& mr, 
     std::complex<float> dAlpha,
     basic_cmatrix<float, std::complex<float> >& mRes,
     std::complex<float> dBeta)
{
    CHEMM (bLeft ? gC<float>().pL() : gC<float>().pR(),
#if defined (_MSC_VER)
           1,
#endif
           gC<float>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           mRes._pm(), mRes._pn(),
           &dAlpha,
           ml._pd(), ml._pld(),
           mr._pd(), mr._pld(),
           &dBeta,
           mRes, mRes._pld());
}

template<>
CVM_API void
__hemm<std::complex<double>, basic_schmatrix<double, std::complex<double> >, basic_cmatrix<double, std::complex<double> > >
    (bool bLeft,
     const basic_schmatrix<double, std::complex<double> >& ml,
     const basic_cmatrix<double, std::complex<double> >& mr, 
     std::complex<double> dAlpha,
     basic_cmatrix<double, std::complex<double> >& mRes,
     std::complex<double> dBeta)
{
    ZHEMM (bLeft ? gC<double>().pL() : gC<double>().pR(),
#if defined (_MSC_VER)
           1,
#endif
           gC<double>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           mRes._pm(), mRes._pn(),
           &dAlpha,
           ml._pd(), ml._pld(),
           mr._pd(), mr._pld(),
           &dBeta,
           mRes, mRes._pld());
}

template <>
CVM_API void
__herk<std::complex<float>, basic_schmatrix<float, std::complex<float> > >
    (bool bTransp, 
    std::complex<float> alpha, int k,
    const std::complex<float>* pA, int ldA,
    std::complex<float> beta, basic_schmatrix<float, std::complex<float> >& m)
{
    CHERK (gC<float>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           bTransp ? gC<float>().pC() : gC<float>().pN(),
#if defined (_MSC_VER)
           1,
#endif
           m._pm(), &k, &alpha, pA, &ldA, &beta, m, m._pld());
}

template <>
CVM_API void
__herk<std::complex<double>, basic_schmatrix<double, std::complex<double> > >
    (bool bTransp, 
    std::complex<double> alpha, int k,
    const std::complex<double>* pA, int ldA,
    std::complex<double> beta, basic_schmatrix<double, std::complex<double> >& m)
{
    ZHERK (gC<double>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           bTransp ? gC<double>().pC() : gC<double>().pN(),
#if defined (_MSC_VER)
           1,
#endif
           m._pm(), &k, &alpha, pA, &ldA, &beta, m, m._pld());
}

template <>
CVM_API void
__her2k<std::complex<float>, basic_schmatrix<float, std::complex<float> > >
    (bool bTransp, 
    std::complex<float> alpha, int k,
    const std::complex<float>* pA, int ldA,
    const std::complex<float>* pB, int ldB,
    std::complex<float> beta, basic_schmatrix<float, std::complex<float> >& m)
{
    CHER2K (gC<float>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           bTransp ? gC<float>().pC() : gC<float>().pN(),
#if defined (_MSC_VER)
           1,
#endif
           m._pm(), &k, &alpha, pA, &ldA, pB, &ldB, &beta, m, m._pld());
}

template <>
CVM_API void
__her2k<std::complex<double>, basic_schmatrix<double, std::complex<double> > >
    (bool bTransp, 
    std::complex<double> alpha, int k,
    const std::complex<double>* pA, int ldA,
    const std::complex<double>* pB, int ldB,
    std::complex<double> beta, basic_schmatrix<double, std::complex<double> >& m)
{
    ZHER2K (gC<double>().pU(),
#if defined (_MSC_VER)
           1,
#endif
           bTransp ? gC<double>().pC() : gC<double>().pN(),
#if defined (_MSC_VER)
           1,
#endif
           m._pm(), &k, &alpha, pA, &ldA, pB, &ldB, &beta, m, m._pld());
}

CVM_NAMESPACE_END
