コード例 #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
ファイル: 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());
            }
        }
コード例 #4
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);
        }
コード例 #5
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());
            }
        }
コード例 #6
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();
        }
コード例 #7
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++;
     } 
 }
コード例 #8
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;


        }
コード例 #9
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;

        }
コード例 #10
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;
        }
コード例 #11
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;
        }
コード例 #12
0
 public static double[] ComputeEigenVector(Eigen eigen, int i)
 {  
     return eigen.GetEigenVector(i).ToArray(); ;
 }
コード例 #13
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;
 }