コード例 #1
0
ファイル: GCDMatrix.cpp プロジェクト: nooperpudd/Elemental
void GCDMatrix( AbstractDistMatrix<T>& G, Int m, Int n )
{
    DEBUG_ONLY(CSE cse("GCDMatrix"))
    G.Resize( m, n );
    auto gcdFill = []( Int i, Int j ) { return T(GCD(i+1,j+1)); };
    IndexDependentFill( G, function<T(Int,Int)>(gcdFill) );
}
コード例 #2
0
ファイル: MinIJ.cpp プロジェクト: bluehope/Elemental
void MinIJ( AbstractDistMatrix<T>& M, Int n )
{
    DEBUG_ONLY(CSE cse("MinIJ"))
    M.Resize( n, n );
    auto minIJFill = []( Int i, Int j ) { return T(Min(i+1,j+1)); };
    IndexDependentFill( M, function<T(Int,Int)>(minIJFill) );
}
コード例 #3
0
ファイル: Hilbert.cpp プロジェクト: AmiArnab/Elemental
void Hilbert( AbstractDistMatrix<F>& A, Int n )
{
    DEBUG_ONLY(CSE cse("Hilbert"))
    A.Resize( n, n );
    auto hilbertFill = []( Int i, Int j ) { return F(1)/F(i+j+1); };
    IndexDependentFill( A, function<F(Int,Int)>(hilbertFill) );
}
コード例 #4
0
ファイル: Parter.cpp プロジェクト: sg0/Elemental
void Parter( AbstractBlockDistMatrix<F>& P, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Parter"))
    P.Resize( n, n );
    const F oneHalf = F(1)/F(2);
    auto parterFill = [=]( Int i, Int j ) { return F(1)/(F(i)-F(j)+oneHalf); };
    IndexDependentFill( P, function<F(Int,Int)>(parterFill) );
}
コード例 #5
0
ファイル: Ris.cpp プロジェクト: sg0/Elemental
void Ris( AbstractBlockDistMatrix<F>& R, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Ris"))
    R.Resize( n, n );
    const F oneHalf = F(1)/F(2);
    auto risFill = [=]( Int i, Int j ) { return oneHalf/(F(n-i-j)-oneHalf); };
    IndexDependentFill( R, function<F(Int,Int)>(risFill) );
}
コード例 #6
0
ファイル: Ris.cpp プロジェクト: YingzhouLi/Elemental
void Ris( AbstractDistMatrix<F>& R, Int n )
{
    DEBUG_CSE
    R.Resize( n, n );
    const F oneHalf = F(1)/F(2);
    auto risFill = [=]( Int i, Int j ) { return oneHalf/(F(n-i-j)-oneHalf); };
    IndexDependentFill( R, function<F(Int,Int)>(risFill) );
}
コード例 #7
0
ファイル: Parter.cpp プロジェクト: elemental/Elemental
void Parter( AbstractDistMatrix<F>& P, Int n )
{
    EL_DEBUG_CSE
    P.Resize( n, n );
    const F oneHalf = F(1)/F(2);
    auto parterFill = [=]( Int i, Int j ) { return F(1)/(F(i)-F(j)+oneHalf); };
    IndexDependentFill( P, function<F(Int,Int)>(parterFill) );
}
コード例 #8
0
ファイル: Lehmer.cpp プロジェクト: AmiArnab/Elemental
void Lehmer( AbstractDistMatrix<F>& L, Int n )
{
    DEBUG_ONLY(CSE cse("Lehmer"))
    L.Resize( n, n );
    auto lehmerFill = 
      []( Int i, Int j ) -> F
      { if( i < j ) { return F(i+1)/F(j+1); }
        else        { return F(j+1)/F(i+1); } };
    IndexDependentFill( L, function<F(Int,Int)>(lehmerFill) );
}
コード例 #9
0
ファイル: KMS.cpp プロジェクト: jakebolewski/Elemental
void KMS( AbstractBlockDistMatrix<T>& K, Int n, T rho )
{
    DEBUG_ONLY(CallStackEntry cse("KMS"))
    K.Resize( n, n );
    auto kmsFill = 
      [=]( Int i, Int j ) -> T
      { if( i < j ) { return Pow(rho,T(j-i));       } 
        else        { return Conj(Pow(rho,T(i-j))); } };
    IndexDependentFill( K, function<T(Int,Int)>(kmsFill) );
}
コード例 #10
0
ファイル: Toeplitz.cpp プロジェクト: elemental/Elemental
void Toeplitz( AbstractDistMatrix<S>& A, Int m, Int n, const vector<T>& a )
{
    EL_DEBUG_CSE
    const Int length = m+n-1;
    if( a.size() != Unsigned(length) )
        LogicError("a was the wrong size");
    A.Resize( m, n );
    auto toeplitzFill = [&]( Int i, Int j ) { return a[i-j+(n-1)]; };
    IndexDependentFill( A, function<S(Int,Int)>(toeplitzFill) );
}
コード例 #11
0
ファイル: Redheffer.cpp プロジェクト: birm/Elemental
void Redheffer( AbstractBlockDistMatrix<T>& R, Int n )
{
    DEBUG_ONLY(CSE cse("Redheffer"))
    R.Resize( n, n );
    auto redhefferFill = 
      []( Int i, Int j ) -> T
      { if( j == 0 || ((j+1)%(i+1))==0 ) { return T(1); }
        else                             { return T(0); } };
    IndexDependentFill( R, function<T(Int,Int)>(redhefferFill) );
}
コード例 #12
0
ファイル: Egorov.cpp プロジェクト: restrin/Elemental
void Egorov
( Matrix<Complex<Real>>& A, function<Real(Int,Int)> phase, Int n )
{
    DEBUG_ONLY(CSE cse("Egorov"))
    A.Resize( n, n );
    auto egorovFill = 
      [&]( Int i, Int j ) -> Complex<Real>
      { const Real theta = phase(i,j);
        return Complex<Real>(Cos(theta),Sin(theta)); }; 
    IndexDependentFill( A, function<Complex<Real>(Int,Int)>(egorovFill) );
}
コード例 #13
0
ファイル: GKS.cpp プロジェクト: jakebolewski/Elemental
void GKS( AbstractBlockDistMatrix<F>& A, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("GKS"))
    A.Resize( n, n );
    auto gksFill = 
      []( Int i, Int j ) -> F
      { if( i < j )       { return -F(1)/Sqrt(F(j+1)); }
        else if( i == j ) { return  F(1)/Sqrt(F(j+1)); }
        else              { return  F(0);            } };
    IndexDependentFill( A, function<F(Int,Int)>(gksFill) );
}
コード例 #14
0
ファイル: KMS.cpp プロジェクト: elemental/Elemental
void KMS( AbstractDistMatrix<T>& K, Int n, T rho )
{
    EL_DEBUG_CSE
    K.Resize( n, n );
    auto kmsFill =
        [=]( Int i, Int j ) -> T
{   if( i < j ) {
            return Pow(rho,T(j-i));
        }
        else        { return Conj(Pow(rho,T(i-j))); } };
    IndexDependentFill( K, function<T(Int,Int)>(kmsFill) );
}
コード例 #15
0
ファイル: Fourier.cpp プロジェクト: sg0/Elemental
void Fourier( AbstractBlockDistMatrix<Complex<Real>>& A, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Fourier"))
    A.Resize( n, n );
    const Real pi = 4*Atan( Real(1) );
    const Real nSqrt = Sqrt( Real(n) );
    auto fourierFill = 
      [=]( Int i, Int j ) -> Complex<Real>
      { const Real theta = -2*pi*i*j/n;
        return Complex<Real>(Cos(theta),Sin(theta))/nSqrt; };
    IndexDependentFill( A, function<Complex<Real>(Int,Int)>(fourierFill) );
}
コード例 #16
0
ファイル: Fourier.cpp プロジェクト: elemental/Elemental
void Fourier( Matrix<Complex<Real>>& A, Int n )
{
    EL_DEBUG_CSE
    A.Resize( n, n );
    const Real pi = 4*Atan( Real(1) );
    const Real nSqrt = Sqrt( Real(n) );
    auto fourierFill =
      [=]( Int i, Int j ) -> Complex<Real>
      { const Real theta = -2*pi*i*j/n;
        return Complex<Real>(Cos(theta),Sin(theta))/nSqrt; };
    IndexDependentFill( A, function<Complex<Real>(Int,Int)>(fourierFill) );
}
コード例 #17
0
ファイル: Egorov.cpp プロジェクト: arbenson/Elemental
void Egorov
( AbstractBlockDistMatrix<Complex<Real>>& A,
  std::function<Real(Int,Int)> phase, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Egorov"))
    A.Resize( n, n );
    auto egorovFill = 
      [&]( Int i, Int j )
      { const Real theta = phase(i,j);
        return Complex<Real>(Cos(theta),Sin(theta)); }; 
    IndexDependentFill( A, std::function<Complex<Real>(Int,Int)>(egorovFill) );
}
コード例 #18
0
ファイル: Kahan.cpp プロジェクト: bluehope/Elemental
void Kahan( AbstractDistMatrix<F>& A, Int n, F phi )
{
    DEBUG_ONLY(CSE cse("Kahan"))
    A.Resize( n, n );
    const F zeta = Sqrt(F(1)-phi*Conj(phi));
    typedef Base<F> Real;
    auto kahanFill = 
      [=]( Int i, Int j ) -> F
      { if( i == j )      { return      Pow(zeta,Real(i)); }
        else if(  i < j ) { return -phi*Pow(zeta,Real(i)); }
        else              { return F(0);                   } };
    IndexDependentFill( A, function<F(Int,Int)>(kahanFill) );
}
コード例 #19
0
ファイル: Riffle.cpp プロジェクト: YingzhouLi/Elemental
void Riffle( AbstractDistMatrix<F>& P, Int n )
{
    DEBUG_CSE
    typedef Base<F> Real;

    auto logBinom = LogBinomial<Real>( n+1 );
    auto logEuler = LogEulerian<Real>( n );

    const Real gamma = n*Log(Real(2));

    P.Resize( n, n );
    auto riffleFill = 
      [&]( Int i, Int j ) -> F
      { const Int k = 2*i - j + 1;
        if( k >= 0 && k <= n+1 )
            return Exp(logBinom[k]-gamma+logEuler[j]-logEuler[i]);
        else
            return Base<F>(0); 
      };
    IndexDependentFill( P, function<F(Int,Int)>(riffleFill) );
}
コード例 #20
0
ファイル: Riffle.cpp プロジェクト: YingzhouLi/Elemental
void RiffleStationary( AbstractDistMatrix<F>& PInf, Int n )
{
    DEBUG_CSE
    typedef Base<F> Real;
    // NOTE: This currently requires quadratic time
    vector<Real> sigma(n,0), sigmaTmp(n,0);
    sigma[0] = sigmaTmp[0] = 1;
    for( Int j=1; j<n; ++j )
    {
        sigmaTmp[0] = sigma[0];
        for( Int k=1; k<=j; ++k )
            sigmaTmp[k] = (k+1)*sigma[k] + (j-k+1)*sigma[k-1];
        for( Int k=0; k<n; ++k )
            sigma[k] = sigmaTmp[k]/(j+1);
    }
    SwapClear( sigmaTmp );

    PInf.Resize( n, n );
    auto riffleStatFill = [&]( Int i, Int j ) { return sigma[j]; };
    IndexDependentFill( PInf, function<F(Int,Int)>(riffleStatFill) );
}