コード例 #1
0
 public static double[] ComputeDistanceDiffusion(int originVertexIndex, 
                                                 double parameterT, 
                                                 Eigen eigens)
 {
     double[] diffusionDistance = new double[eigens.EigenVectorSize];
     for (int i = 0; i < diffusionDistance.Length; i++)
     {
         diffusionDistance[i] = 0;
     }
     double optParamterT =parameterT / (2 * eigens.GetEigenValue(1));
     for (int i = 1; i < eigens.Count; i++)
     {
         EigenPair pair = eigens.SortedEigens[i];
         double eigenValue = pair.EigenValue;
         List<double> eigenVector = pair.EigenVector;                          
         for (int j = 0; j < eigenVector.Count; j++)
         {
             double orig = eigenVector[originVertexIndex];
             double y = eigenVector[j];
             double res = orig - y;
             diffusionDistance[j] += Math.Exp(-2 * optParamterT * eigenValue) 
                                     * (res * res);                  
         }
                   
     }
     for (int i = 0; i < diffusionDistance.Length; i++)
     {
         diffusionDistance[i] = Math.Sqrt(diffusionDistance[i]);    
     }
     return diffusionDistance;
 }
コード例 #2
0
        public static double[] ComputeDistanceCommuteTime(int originVertexIndex, 
                                                          Eigen eigens)
        {
            double[] diffusionDistance = new double[eigens.EigenVectorSize];
            for (int i = 0; i < diffusionDistance.Length; i++)
            {
                diffusionDistance[i] = 0;
            } 
            for (int i = 1; i < eigens.Count; i++)
            {
                EigenPair pair = eigens.SortedEigens[i];
                double eigenValue = pair.EigenValue;
                List<double> eigenVector = pair.EigenVector;
                for (int j = 0; j < eigenVector.Count; j++)
                {
                    double orig = eigenVector[originVertexIndex];
                    double y = eigenVector[j];
                    double res = orig - y;
                    diffusionDistance[j] +=  (1/eigenValue) * (res * res);
                }

            }
            for (int i = 0; i < diffusionDistance.Length; i++)
            {
                diffusionDistance[i] = Math.Sqrt(diffusionDistance[i]);
            }
            return diffusionDistance;
        }
コード例 #3
0
        private void InitEigenValue(Eigen eigen)
        {
            this.dataGridViewEigenValue.Rows.Clear();

            for (int i = 0; i < eigen.Count; i++)
            {
                this.dataGridViewEigenValue.Rows.Add(i.ToString(), eigen.GetEigenValue(i).ToString());
            }
        }
コード例 #4
0
ファイル: FormEigenMatrix.cs プロジェクト: meshdgp/MeshDGP
        private void InitEigenValue(Eigen eigen)
        {
            this.dataGridViewEigenValue.Rows.Clear();

            for (int i = 0; i < eigen.Count; i++)
            {
                this.dataGridViewEigenValue.Rows.Add(i.ToString(), eigen.GetEigenValue(i).ToString());
            }
        }
コード例 #5
0
        public Eigen ComputeEigensByLib(SparseMatrix sparse, int count)
        {
            SparseMatrixDouble ds = new SparseMatrixDouble(sparse);


            Eigen eigen = ComputeEigensByLib(ds, 0.0, count);

            return(eigen);
        }
コード例 #6
0
        private void dumpButton_Click(object sender, EventArgs e)
        {
            EnumLaplaceMatrix type = (EnumLaplaceMatrix)this.comboBoxLaplaceType.SelectedItem;

            int count = int.Parse(textBoxEigenNumber.Text);

            eigen = EigenManager.Instance.ComputeEigen(Mesh, type, count);

            InitEigenValue(eigen);
        }
コード例 #7
0
ファイル: FormEigenMatrix.cs プロジェクト: meshdgp/MeshDGP
        private void dumpButton_Click(object sender, EventArgs e)
        {
            EnumLaplaceMatrix type = (EnumLaplaceMatrix)this.comboBoxLaplaceType.SelectedItem;

            int count = int.Parse(textBoxEigenNumber.Text);

            eigen=EigenManager.Instance.ComputeEigen(Mesh, type, count);

            InitEigenValue(eigen);
        }
コード例 #8
0
        public Eigen ComputeEigensByLib(SparseMatrixDouble sparse, double sigma, int count)
        {
            int[]    pCol;
            int[]    iRow;
            double[] Values;
            int      NNZ;

            int m = sparse.RowCount;

            sparse.ToCCS(out pCol, out iRow, out Values, out NNZ);

            double[] ImagePart = new double[count];
            double[] RealPart  = new double[count];
            double[] Vectors   = new double[count * m];

            fixed(int *ri = iRow, cp = pCol)
            fixed(double *val = Values, vets = Vectors, imgPart = ImagePart, relPart = RealPart)
            {
                int result = ComputeEigenNoSymmetricShiftModeCRS(ri, cp, val, NNZ, m, count, sigma, relPart, imgPart, vets);
            }



            List <EigenPair> list = new List <EigenPair>();

            for (int i = 0; i < count; i++)
            {
                double realPart = RealPart[i];



                List <double> vector = new List <double>();

                int startIndex = i * m;
                int endIndex   = i * m + m;

                for (int j = startIndex; j < endIndex; j++)
                {
                    double value = Vectors[j];
                    vector.Add(value);
                }

                EigenPair newPair = new EigenPair(realPart, vector);


                list.Add(newPair);
            }

            list.Sort();

            Eigen eigen = new Eigen();

            eigen.SortedEigens = list.ToArray();
            return(eigen);
        }
コード例 #9
0
        private void InitEigenVector(Eigen eigen, int index)
        {
            this.dataGridViewEigenVector.Rows.Clear();

            double[] vector = eigen.GetEigenVector(index).ToArray();

            for (int i = 0; i < vector.Length; i++)
            {
                this.dataGridViewEigenVector.Rows.Add(i.ToString(), vector[i].ToString());
            }
        }
コード例 #10
0
ファイル: FormEigenMatrix.cs プロジェクト: meshdgp/MeshDGP
        private void InitEigenVector(Eigen eigen,int index)
        {
            this.dataGridViewEigenVector.Rows.Clear();

            double[] vector = eigen.GetEigenVector(index).ToArray();

            for (int i = 0; i < vector.Length ; i++)
            {
                this.dataGridViewEigenVector.Rows.Add(i.ToString(), vector[i].ToString());
            }
        }
コード例 #11
0
        public double[] ColorEigenVector(TriMesh mesh, int index)
        {
            if (eigen == null)
            {
                eigen = EigenManager.Instance.ComputeEigen(mesh, eigenCount);
            }

            if (eigenIndex > eigenCount)
            {
                eigen = EigenManager.Instance.ComputeEigen(mesh, eigenCount);
            }
            return(eigen.GetEigenVector(eigenIndex).ToArray());
        }
コード例 #12
0
ファイル: TriMeshVertexColor.cs プロジェクト: meshdgp/MeshDGP
        public double[] ColorEigenVector(TriMesh mesh, int index)
        {
            if (eigen == null)
            {
                eigen = EigenManager.Instance.ComputeEigen(mesh, eigenCount);
            }

            if (eigenIndex > eigenCount)
            {
                eigen = EigenManager.Instance.ComputeEigen(mesh, eigenCount);
            }
            return eigen.GetEigenVector(eigenIndex).ToArray();
        }
コード例 #13
0
        public TriMesh Recon(TriMesh mesh, int reconNum)
        {
            Eigen eigen = EigenManager.Instance.ComputeEigen(mesh,
                                                             EnumLaplaceMatrix.LapalceCot, reconNum + 10);

            List <double> X = TriMeshUtil.GetX(mesh);
            List <double> Y = TriMeshUtil.GetY(mesh);
            List <double> Z = TriMeshUtil.GetZ(mesh);

            List <double> factorX = new List <double>(reconNum);
            List <double> factorY = new List <double>(reconNum);
            List <double> factorZ = new List <double>(reconNum);

            for (int i = 0; i < reconNum; i++)
            {
                List <double> eigenVector = eigen.GetEigenVector(i);
                double        valueX      = TriMeshUtil.Multiply(eigenVector, X);
                double        valueY      = TriMeshUtil.Multiply(eigenVector, Y);
                double        valueZ      = TriMeshUtil.Multiply(eigenVector, Z);
                factorX.Add(valueX);
                factorY.Add(valueY);
                factorZ.Add(valueZ);
            }


            double[] reconX = new double[mesh.Vertices.Count];
            double[] reconY = new double[mesh.Vertices.Count];
            double[] reconZ = new double[mesh.Vertices.Count];
            for (int i = 0; i < reconNum; i++)
            {
                List <double> eigenVector = eigen.GetEigenVector(i);
                List <double> tempX       = TriMeshUtil.Multiply(eigenVector, factorX[i]);
                reconX = TriMeshUtil.Add(reconX, tempX);

                List <double> tempY = TriMeshUtil.Multiply(eigenVector, factorY[i]);
                reconY = TriMeshUtil.Add(reconY, tempY);
                List <double> tempZ = TriMeshUtil.Multiply(eigenVector, factorZ[i]);
                reconZ = TriMeshUtil.Add(reconZ, tempZ);
            }

            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                mesh.Vertices[i].Traits.Position.x = reconX[i];
                mesh.Vertices[i].Traits.Position.y = reconY[i];
                mesh.Vertices[i].Traits.Position.z = reconZ[i];
            }


            return(mesh);
        }
コード例 #14
0
        public static double[] ComputeDistanceADF(TriMesh mesh, double parameterT, Eigen eigens)
        {
            double[] adfValues = new double[mesh.Vertices.Count];

            for (int j = 1; j < eigens.Count; j++)
            {
                List <double> group = eigens.SortedEigens[j].EigenVector;
                for (int i = 0; i < group.Count; i++)
                {
                    adfValues[i] += Math.Exp(-parameterT * (eigens.SortedEigens[j].EigenValue / eigens.SortedEigens[1].EigenValue)) *
                                    (group[i] * group[i]);
                }
            }

            return(adfValues);
        }
コード例 #15
0
ファイル: MenuMatlab.cs プロジェクト: meshdgp/MeshDGP
 private void InitEigen(ToolStripMenuItem toolStrip, Eigen eigen)
 {
     toolStrip.DropDownItems.Clear();
     int i = 0;
     foreach (EigenPair pair in eigen.SortedEigens)
     {
        
         ToolStripMenuItem item = new ToolStripMenuItem();
         item.Name = i.ToString() + "ToolStripMenuItem";
         item.Text = i.ToString();
         item.Tag = i;
         item.Click += eigen_Click;
         toolStrip.DropDownItems.Add(item);
         i++;
     } 
 }
コード例 #16
0
        private void InitEigen(ToolStripMenuItem toolStrip, Eigen eigen)
        {
            toolStrip.DropDownItems.Clear();
            int i = 0;

            foreach (EigenPair pair in eigen.SortedEigens)
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Name   = i.ToString() + "ToolStripMenuItem";
                item.Text   = i.ToString();
                item.Tag    = i;
                item.Click += eigen_Click;
                toolStrip.DropDownItems.Add(item);
                i++;
            }
        }
コード例 #17
0
        public static double[] ComputeEigenVector(TriMesh mesh, int i)
        {
            SparseMatrix matrix = null;

            if (LaplaceManager.Instance.CurrentMatrix == null)
            {
                matrix = LaplaceManager.Instance.BuildMatrixCot(mesh);
            }
            else
            {
                matrix = LaplaceManager.Instance.CurrentMatrix;
            }

            Eigen eigen = EigenManager.Instance.ComputeEigen(matrix, "test", i + 2);

            return(eigen.GetEigenVector(i).ToArray());;
        }
コード例 #18
0
        public static double[] ComputeDistanceADF(TriMesh mesh, double parameterT, Eigen eigens)
        {
            double[] adfValues = new double[mesh.Vertices.Count];

            for (int j = 1; j < eigens.Count; j++)
            {
                List<double> group = eigens.SortedEigens[j].EigenVector;
                for (int i = 0; i < group.Count; i++)
                {
                    adfValues[i] += Math.Exp(-parameterT * (eigens.SortedEigens[j].EigenValue / eigens.SortedEigens[1].EigenValue)) *
                        (group[i] * group[i]);
                }
            }

            return adfValues;


        }
コード例 #19
0
        public Eigen GetEigen(SparseMatrix sparse, int num)
        {
            OutPut(sparse, "L");
            matlab.Execute(@"[EV,ED] = eigs(L," + num.ToString() + ",'sm') ");

            double[,] eigVector = GetMatrix("EV");
            double[,] eigValue  = GetMatrix("ED");

            int len = eigVector.GetLength(0);
            List <EigenPair> list = new List <EigenPair>();

            for (int i = 0; i < num; i++)
            {
                double realPart = eigValue[i, i];

                List <double> vector = new List <double>();

                for (int j = 0; j < len; j++)
                {
                    double value = eigVector[j, i];
                    vector.Add(value);
                }

                EigenPair newPair = new EigenPair(realPart, vector);


                list.Add(newPair);
            }

            list.Sort();

            Eigen eigen = new Eigen();

            eigen.SortedEigens = list.ToArray();

            return(eigen);
        }
コード例 #20
0
 public static double[] ComputeEigenVector(Eigen eigen, int i)
 {
     return(eigen.GetEigenVector(i).ToArray());;
 }
コード例 #21
0
        public static double[] ComputeEigenVector(SparseMatrix matrix, int i)
        {
            Eigen eigen = EigenManager.Instance.ComputeEigen(matrix, "test", i + 20);

            return(eigen.GetEigenVector(i).ToArray());;
        }
コード例 #22
0
ファイル: MatlabBasic.cs プロジェクト: meshdgp/MeshDGP
        public Eigen GetEigen(SparseMatrix sparse, int num)
        {
            OutPut(sparse, "L");
            matlab.Execute(@"[EV,ED] = eigs(L," + num.ToString() + ",'sm') ");

            double[,] eigVector = GetMatrix("EV");
            double[,] eigValue = GetMatrix("ED");
             
            int len=eigVector.GetLength(0);
            List<EigenPair> list = new List<EigenPair>();

            for (int i = 0; i < num; i++)
            {
                double realPart = eigValue[i,i];  

                List<double> vector = new List<double>();

                for (int j = 0; j < len; j++)
                {
                    double value = eigVector[j,i];
                    vector.Add(value);
                }

                EigenPair newPair = new EigenPair(realPart, vector);


                list.Add(newPair);
            }

            list.Sort();

            Eigen eigen = new Eigen();
            eigen.SortedEigens = list.ToArray();  
             
            return eigen;

        }
コード例 #23
0
        public Eigen  ComputeEigen(SparseMatrix matrix, string modelName, int count)
        {
            Eigen eigen = LinearSystem.Instance.ComputeEigen(matrix, count, modelName);

            return(eigen);
        }
コード例 #24
0
 public static double[] ComputeDistanceBiharmonic(int sourceVertex, Eigen eigens)
 { 
     double[] biharmonicDistance = new double[eigens.EigenVectorSize];
     for (int i = 0; i < biharmonicDistance.Length; i++)
     {
         biharmonicDistance[i] = 0;
     } 
     for (int i = 1; i < eigens.Count; i++)
     {
         EigenPair pair = eigens.SortedEigens[i]; 
         double eigenValue = pair.EigenValue; 
         List<double> eigenVector = pair.EigenVector;  
         for (int j = 0; j < eigenVector.Count; j++)
         {
             double orig = eigenVector[sourceVertex];
             double y = eigenVector[j];
             double res = orig - y;
             biharmonicDistance[j] += (res * res)/((eigenValue) * (eigenValue)); 
         }
     } 
     for (int i = 0; i < biharmonicDistance.Length; i++)
     {
         biharmonicDistance[i] = Math.Sqrt(biharmonicDistance[i]);
     } 
     return biharmonicDistance;
 }
コード例 #25
0
 public static double[] ComputeEigenVector(Eigen eigen, int i)
 {  
     return eigen.GetEigenVector(i).ToArray(); ;
 }
コード例 #26
0
ファイル: IOHuizhao.cs プロジェクト: meshdgp/MeshDGP
        public Eigen ReadEigen(string modelName)
        {
            string fileName = Path.GetFileNameWithoutExtension(modelName);
            string path = GetPath() + fileName + ".eigens";

            Eigen eigen = new Eigen();
            List<EigenPair> list = new List<EigenPair>();

            //Read File
            using (StreamReader sr = new StreamReader(path))
            {
                String line = null;
                List<double> currentVector = null;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line != "" && line[0] == '#')
                    {
                        String[] tokens = line.Split(' ');
                        List<double> aVector = new List<double>();
                        currentVector = aVector;

                        EigenPair pair = new EigenPair(double.Parse(tokens[1]), aVector);
                        list.Add(pair);
                    }
                    else if (line != "")
                    {
                        double value = double.Parse(line);
                        currentVector.Add(value);
                    }
                }
            }
            list.Sort();
            eigen.SortedEigens = list.ToArray();
            return eigen;
        }
コード例 #27
0
ファイル: LinearEigenVector.cs プロジェクト: meshdgp/MeshDGP
        public Eigen ComputeEigensByLib(SparseMatrixDouble sparse, double sigma, int count)
        {
            int[] pCol;
            int[] iRow;
            double[] Values;
            int NNZ;

            int m = sparse.RowCount;

            sparse.ToCCS(out pCol, out iRow, out Values, out NNZ);

            double[] ImagePart = new double[count];
            double[] RealPart = new double[count];
            double[] Vectors = new double[count * m];

            fixed (int* ri = iRow, cp = pCol)
            fixed (double* val = Values, vets = Vectors, imgPart = ImagePart, relPart = RealPart)
            {
                int result = ComputeEigenNoSymmetricShiftModeCRS(ri, cp, val, NNZ, m, count, sigma, relPart, imgPart, vets);
            }

           

            List<EigenPair> list = new List<EigenPair>();

            for (int i = 0; i < count; i++)
            {
                double realPart = RealPart[i];

                 

                List<double> vector = new List<double>();

                int startIndex = i * m;
                int endIndex = i * m + m;

                for (int j = startIndex; j < endIndex; j++)
                {
                    double value = Vectors[j];
                    vector.Add(value);
                }

                EigenPair newPair = new EigenPair(realPart, vector);


                list.Add(newPair);
            }

            list.Sort();

            Eigen eigen = new Eigen();
            eigen.SortedEigens = list.ToArray();
            return eigen;
        }