Exemple #1
0
            public static void SelfTest()
            {
                Matlab.NumericSolver.Register();
                //{
                //    Pdb pdb = Pdb.FromPdbid("1GIA");
                //    List<Pdb.Atom> atoms = pdb.atoms.SelectByChainID().SelectByAltLoc().SelectByName("CA");
                //    List<Vector> coords = atoms.ListCoord();
                //    Matlab.PutMatrix("coords", coords.ToMatrix(false));
                //    Matlab.PutMatrix("hv_mine", GetHessCa(coords));
                //    Matlab.Execute("[hv1,hv2,hv3,hv4] = STeM(coords);");
                //    Matlab.Execute("hv_tul = hv1 + hv2 + hv3 + hv4;");
                //    Matlab.Execute("hv_diff = hv_mine - hv_tul;");
                //    Matlab.Execute("max(max(abs(hv_diff)));");
                //    // ans = 2.4158e-13
                //}


                if (_SelfTest == false)
                {
                    return;
                }
                _SelfTest = false;

                Random rand = new Random();

                Vector[] caArray = new Vector[100];
                for (int i = 0; i < caArray.Length; i++)
                {
                    caArray[i] = new double[3] {
                        rand.NextDouble() *100, rand.NextDouble() *100, rand.NextDouble() *100
                    }
                }
                ;

                HessMatrix hess0;

                hess0 = GetHessCa_matlab(caArray);

                HessMatrix hess1 = GetHessCa(caArray);
                HessMatrix hess2 = GetHessCa_v2(caArray);

                HDebug.Assert(HDebug.CheckToleranceMatrix(0.00000001, hess1 - hess2));
                HDebug.Assert(HDebug.CheckToleranceMatrix(0.00000001, hess0 - hess1));
                HDebug.Assert(HDebug.CheckToleranceMatrix(0.00000001, hess0 - hess2));


                HDebug.Assert(SelfTest_1AAC());
            }