Exemplo n.º 1
0
 /*************************************************************************
 Unsets report
 *************************************************************************/
 private static void unsetrep(matinv.matinvreport r)
 {
     r.r1 = -1;
     r.rinf = -1;
 }
Exemplo n.º 2
0
        /*************************************************************************
        Checks whether inversion result indicate singular matrix
        Returns True on success.
        *************************************************************************/
        private static bool cmatrixcheckinversesingular(complex[,] inva,
            int n,
            double threshold,
            int info,
            matinv.matinvreport rep)
        {
            bool result = new bool();
            int i = 0;
            int j = 0;

            result = true;
            if( info!=-3 & info!=1 )
            {
                result = false;
            }
            else
            {
                result = result & !((double)(rep.r1)<(double)(0) | (double)(rep.r1)>(double)(1000*math.machineepsilon));
                result = result & !((double)(rep.rinf)<(double)(0) | (double)(rep.rinf)>(double)(1000*math.machineepsilon));
                if( info==-3 )
                {
                    for(i=0; i<=n-1; i++)
                    {
                        for(j=0; j<=n-1; j++)
                        {
                            result = result & inva[i,j]==0;
                        }
                    }
                }
            }
            return result;
        }
Exemplo n.º 3
0
        /*************************************************************************
        Checks whether inverse is correct
        Returns True on success.
        *************************************************************************/
        private static bool spdmatrixcheckinverse(double[,] a,
            double[,] inva,
            bool isupper,
            int n,
            double threshold,
            int info,
            matinv.matinvreport rep)
        {
            bool result = new bool();
            int i = 0;
            int j = 0;
            double v = 0;
            int i_ = 0;

            a = (double[,])a.Clone();
            inva = (double[,])inva.Clone();

            for(i=0; i<=n-2; i++)
            {
                if( isupper )
                {
                    for(i_=i+1; i_<=n-1;i_++)
                    {
                        a[i_,i] = a[i,i_];
                    }
                    for(i_=i+1; i_<=n-1;i_++)
                    {
                        inva[i_,i] = inva[i,i_];
                    }
                }
                else
                {
                    for(i_=i+1; i_<=n-1;i_++)
                    {
                        a[i,i_] = a[i_,i];
                    }
                    for(i_=i+1; i_<=n-1;i_++)
                    {
                        inva[i,i_] = inva[i_,i];
                    }
                }
            }
            result = true;
            if( info<=0 )
            {
                result = false;
            }
            else
            {
                result = result & !((double)(rep.r1)<(double)(100*math.machineepsilon) | (double)(rep.r1)>(double)(1+1000*math.machineepsilon));
                result = result & !((double)(rep.rinf)<(double)(100*math.machineepsilon) | (double)(rep.rinf)>(double)(1+1000*math.machineepsilon));
                for(i=0; i<=n-1; i++)
                {
                    for(j=0; j<=n-1; j++)
                    {
                        v = 0.0;
                        for(i_=0; i_<=n-1;i_++)
                        {
                            v += a[i,i_]*inva[i_,j];
                        }
                        if( i==j )
                        {
                            v = v-1;
                        }
                        result = result & (double)(Math.Abs(v))<=(double)(threshold);
                    }
                }
            }
            return result;
        }
Exemplo n.º 4
0
        /*************************************************************************
        Checks whether inverse is correct
        Returns True on success.
        *************************************************************************/
        private static bool cmatrixcheckinverse(complex[,] a,
            complex[,] inva,
            int n,
            double threshold,
            int info,
            matinv.matinvreport rep)
        {
            bool result = new bool();
            int i = 0;
            int j = 0;
            complex v = 0;
            int i_ = 0;

            result = true;
            if( info<=0 )
            {
                result = false;
            }
            else
            {
                result = result & !((double)(rep.r1)<(double)(100*math.machineepsilon) | (double)(rep.r1)>(double)(1+1000*math.machineepsilon));
                result = result & !((double)(rep.rinf)<(double)(100*math.machineepsilon) | (double)(rep.rinf)>(double)(1+1000*math.machineepsilon));
                for(i=0; i<=n-1; i++)
                {
                    for(j=0; j<=n-1; j++)
                    {
                        v = 0.0;
                        for(i_=0; i_<=n-1;i_++)
                        {
                            v += a[i,i_]*inva[i_,j];
                        }
                        if( i==j )
                        {
                            v = v-1;
                        }
                        result = result & (double)(math.abscomplex(v))<=(double)(threshold);
                    }
                }
            }
            return result;
        }
Exemplo n.º 5
0
Arquivo: linalg.cs Projeto: Ring-r/opt
 public matinvreport(matinv.matinvreport obj)
 {
     _innerobj = obj;
 }