Esempio n. 1
0
void ThreeValued( Matrix<T>& A, Int m, Int n, double p )
{
    DEBUG_ONLY(CSE cse("ThreeValued"))
    A.Resize( m, n );
    auto tripleCoin = [=]() -> T
    { 
        const double alpha = SampleUniform<double>(0,1);
        if( alpha <= p/2 ) return T(-1);
        else if( alpha <= p ) return T(1);
        else return T(0);
    };
    EntrywiseFill( A, function<T()>(tripleCoin) );
}
Esempio n. 2
0
void MakeGaussian( Matrix<F>& A, F mean, Base<F> stddev )
{
    DEBUG_CSE
    auto sampleNormal = [=]() { return SampleNormal(mean,stddev); };
    EntrywiseFill( A, function<F()>(sampleNormal) );
}
Esempio n. 3
0
void MakeUniform( Matrix<T>& A, T center, Base<T> radius )
{
    EL_DEBUG_CSE
    auto sampleBall = [=]() { return SampleBall(center,radius); };
    EntrywiseFill( A, function<T()>(sampleBall) );
}