当前位置: 首页>>代码示例>>C#>>正文


C# Double.Clone方法代码示例

本文整理汇总了C#中System.Double.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Double.Clone方法的具体用法?C# Double.Clone怎么用?C# Double.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Double的用法示例。


在下文中一共展示了Double.Clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EigenvalueDecomposition

        /// <summary>
        ///   Construct an eigenvalue decomposition.</summary>
        /// <param name="value">
        ///   The matrix to be decomposed.</param>
        /// <param name="assumeSymmetric">
        ///   Defines if the matrix should be assumed as being symmetric
        ///   regardless if it is or not. Default is <see langword="false"/>.</param>
        /// <param name="inPlace">
        ///   Pass <see langword="true"/> to perform the decomposition in place. The matrix
        ///   <paramref name="value"/> will be destroyed in the process, resulting in less
        ///   memory comsumption.</param>
        public EigenvalueDecomposition(Double[,] value, bool assumeSymmetric, bool inPlace)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "Matrix cannot be null.");
            }

            if (value.GetLength(0) != value.GetLength(1))
            {
                throw new ArgumentException("Matrix is not a square matrix.", "value");
            }

            n = value.GetLength(1);
            V = new Double[n, n];
            d = new Double[n];
            e = new Double[n];


            this.symmetric = assumeSymmetric;

            if (this.symmetric)
            {
                V = inPlace ? value : (Double[,])value.Clone();

                // Tridiagonalize.
                this.tred2();

                // Diagonalize.
                this.tql2();
            }
            else
            {
                H = inPlace ? value : (Double[,])value.Clone();

                ort = new Double[n];

                // Reduce to Hessenberg form.
                this.orthes();

                // Reduce Hessenberg to real Schur form.
                this.hqr2();
            }
        }
开发者ID:KommuSoft,项目名称:accord_framework,代码行数:54,代码来源:EigenValueDecomposition.cs

示例2: EigenvalueDecomposition

        /// <summary>
        ///   Construct an eigenvalue decomposition.</summary>
        ///
        /// <param name="value">
        ///   The matrix to be decomposed.</param>
        /// <param name="assumeSymmetric">
        ///   Defines if the matrix should be assumed as being symmetric
        ///   regardless if it is or not. Default is <see langword="false"/>.</param>
        /// <param name="inPlace">
        ///   Pass <see langword="true"/> to perform the decomposition in place. The matrix
        ///   <paramref name="value"/> will be destroyed in the process, resulting in less
        ///   memory comsumption.</param>
        /// <param name="sort">
        ///   Pass <see langword="true"/> to sort the eigenvalues and eigenvectors at the end
        ///   of the decomposition.</param>
        ///
        public EigenvalueDecomposition(Double[,] value, bool assumeSymmetric,
            bool inPlace = false, bool sort = false)
        {
            if (value == null)
                throw new ArgumentNullException("value", "Matrix cannot be null.");

            if (value.GetLength(0) != value.GetLength(1))
                throw new ArgumentException("Matrix is not a square matrix.", "value");

            n = value.GetLength(1);
            V = new Double[n, n];
            d = new Double[n];
            e = new Double[n];


            this.symmetric = assumeSymmetric;

            if (this.symmetric)
            {
                V = inPlace ? value : (Double[,])value.Clone();

                // Tridiagonalize.
                this.tred2();

                // Diagonalize.
                this.tql2();
            }
            else
            {
                H = inPlace ? value : (Double[,])value.Clone();

                ort = new Double[n];

                // Reduce to Hessenberg form.
                this.orthes();

                // Reduce Hessenberg to real Schur form.
                this.hqr2();
            }

            if (sort)
            {
                // Sort eigenvalues and vectors in descending order
                var idx = Vector.Range(n);
                Array.Sort(idx, (i, j) => 
                {
                    if (Math.Abs(d[i]) == Math.Abs(d[j]))
                        return -Math.Abs(e[i]).CompareTo(Math.Abs(e[j]));
                    return -Math.Abs(d[i]).CompareTo(Math.Abs(d[j]));
                });

                this.d = this.d.Get(idx);
                this.e = this.e.Get(idx);
                this.V = this.V.Get(null, idx);
            }
        }
开发者ID:accord-net,项目名称:framework,代码行数:72,代码来源:EigenvalueDecomposition.cs

示例3: SingularValueDecomposition

        private Double[,] v; // right singular vectors

        #endregion Fields

        #region Constructors

        /// <summary>Constructs a new singular value decomposition.</summary>
        /// <param name="value">
        ///   The matrix to be decomposed.</param>
        public SingularValueDecomposition(Double[,] value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "Matrix cannot be null.");
            }

            //m should not less than n
            Double[,] a;
            m = value.GetLength(0); // rows
            n = value.GetLength(1); // cols

            if (m < n)
            {
                throw new System.Exception("rows should not less than cols in value matrix");
            }

            // Proceed anyway
            a = (Double[,])value.Clone();

            int nu = System.Math.Min(m, n);
            int ni = System.Math.Min(m + 1, n);
            s = new Double[ni];
            u = new Double[m, nu];
            v = new Double[n, n];
            Double[] e = new Double[n];
            Double[] work = new Double[m];

            // Will store ordered sequence of indices after sorting.
            si = new int[ni]; for (int i = 0; i < ni; i++) si[i] = i;

            // Reduce A to bidiagonal form, storing the diagonal elements in s and the super-diagonal elements in e.
            int nct = System.Math.Min(m - 1, n);
            int nrt = System.Math.Max(0, System.Math.Min(n - 2, m));
            for (int k = 0; k < System.Math.Max(nct, nrt); k++)
            {
                if (k < nct)
                {
                    // Compute the transformation for the k-th column and place the k-th diagonal in s[k].
                    // Compute 2-norm of k-th column without under/overflow.
                    s[k] = 0;
                    for (int i = k; i < m; i++)
                    {
                        s[k] = Hypotenuse(s[k], a[i, k]);
                    }

                    if (s[k] != 0)
                    {
                        if (a[k, k] < 0)
                            s[k] = -s[k];

                        for (int i = k; i < m; i++)
                            a[i, k] /= s[k];

                        a[k, k] += 1;
                    }

                    s[k] = -s[k];
                }

                for (int j = k + 1; j < n; j++)
                {
                    if ((k < nct) & (s[k] != 0))
                    {
                        // Apply the transformation.
                        Double t = 0;
                        for (int i = k; i < m; i++)
                        {
                            t += a[i, k] * a[i, j];
                        }

                        t = -t / a[k, k];

                        for (int i = k; i < m; i++)
                        {
                            a[i, j] += t * a[i, k];
                        }
                    }

                    // Place the k-th row of A into e for the subsequent calculation of the row transformation.
                    e[j] = a[k, j];
                }

                if (k < nct)
                {
                    // Place the transformation in U for subsequent back
                    // multiplication.
                    for (int i = k; i < m; i++)
                        u[i, k] = a[i, k];
                }

//.........这里部分代码省略.........
开发者ID:JasonWyse,项目名称:AdvUtils,代码行数:101,代码来源:SingularValueDecomposition.cs

示例4: AddResult

            public void AddResult(ResultData r)
            {
                Boolean match = false;
                int indx = -1;
                foreach (MainResults MaRe in results)
                {
                    //match = (MaRe.Latitude == r.Latitude && MaRe.Longitude == r.Longitude);
                    match = (MaRe.OrganizationLocationID == r.OrganizationLocationID);
                    if (match)
                    {
                        indx = results.IndexOf(MaRe);
                        break;
                    }
                }
                if (!match)
                {
                    MainResults mr = new MainResults();
                    mr.TaxID = new String[] { r.TaxID };
                    mr.NPI = new String[] { r.NPI };
                    mr.PracticeName = r.PracticeName;
                    mr.ProviderName = new String[] { r.ProviderName };
                    mr.PracticeRangeMin = String.Format("{0:c0}", decimal.Parse(r.RangeMin));
                    mr.RangeMin = new String[] { r.RangeMin };
                    mr.PracticeRangeMax = String.Format("{0:c0}", decimal.Parse(r.RangeMax));
                    mr.RangeMax = new String[] { r.RangeMax };
                    mr.PracticeYourCostMin = String.Format("{0:c0}", decimal.Parse(r.YourCostMin));
                    mr.YourCostMin = new String[] { r.YourCostMin };
                    mr.PracticeYourCostMax = String.Format("{0:c0}", decimal.Parse(r.YourCostMax));
                    mr.YourCostMax = new String[] { r.YourCostMax };
                    mr.Latitude = r.Latitude;
                    mr.Longitude = r.Longitude;
                    mr.OrganizationLocationID = r.OrganizationLocationID;
                    mr.LocationAddress1 = r.LocationAddress1;
                    mr.LocationCity = r.LocationCity;
                    mr.LocationState = r.LocationState;
                    mr.LocationZip = r.LocationZip;
                    mr.Distance = r.Distance;
                    mr.NumericDistance = r.NumericDistance;
                    mr.PracticeFairPrice = r.FairPrice;
                    mr.FairPrice = new Boolean[] { r.FairPrice };
                    mr.HGRecognized = new Int32[] { r.HGRecognized };
                    switch (r.HGRecognized)
                    {
                        case -1:
                            mr.PracticeHGRecognized = "N/A";
                            break;
                        case 0:
                            mr.PracticeHGRecognized = "0/1 Physicians";
                            break;
                        case 1:
                            mr.PracticeHGRecognized = "1/1 Physicians";
                            break;
                        default:
                            mr.PracticeHGRecognized = "N/A";
                            break;
                    }
                    mr.PracticeAvgRating = r.HGOverallRating;
                    mr.HGOverallRating = new Double[] { r.HGOverallRating };
                    mr.HGPatientCount = new int[] { r.HGPatientCount };
                    results.Add(mr);
                }
                else
                {
                    MainResults mr = results[indx];

                    String[] s = new String[mr.TaxID.Length + 1];
                    mr.TaxID.CopyTo(s, 0);
                    s[s.Length - 1] = r.TaxID;
                    mr.TaxID = (String[])s.Clone();
                    mr.NPI.CopyTo(s, 0);
                    s[s.Length - 1] = r.NPI;
                    mr.NPI = (String[])s.Clone();
                    mr.ProviderName.CopyTo(s, 0);
                    s[s.Length - 1] = r.ProviderName;
                    mr.ProviderName = (String[])s.Clone();

                    mr.RangeMin.CopyTo(s, 0);
                    s[s.Length - 1] = r.RangeMin;
                    mr.RangeMin = (String[])s.Clone();
                    mr.PracticeRangeMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMin.Replace("$", "")) + double.Parse(r.RangeMin)) / 2.0));
                    mr.RangeMax.CopyTo(s, 0);
                    s[s.Length - 1] = r.RangeMax;
                    mr.RangeMax = (String[])s.Clone();
                    mr.PracticeRangeMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeRangeMax.Replace("$", "")) + double.Parse(r.RangeMax)) / 2.0));

                    mr.YourCostMin.CopyTo(s, 0);
                    s[s.Length - 1] = r.YourCostMin;
                    mr.YourCostMin = (String[])s.Clone();
                    mr.PracticeYourCostMin = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMin.Replace("$", "")) + double.Parse(r.YourCostMin)) / 2.0));
                    mr.YourCostMax.CopyTo(s, 0);
                    s[s.Length - 1] = r.YourCostMax;
                    mr.YourCostMax = (String[])s.Clone();
                    mr.PracticeYourCostMax = String.Format("{0:c0}", ((double.Parse(mr.PracticeYourCostMax.Replace("$", "")) + double.Parse(r.YourCostMax)) / 2.0));

                    Boolean[] b = new Boolean[mr.FairPrice.Length + 1];
                    mr.FairPrice.CopyTo(b, 0);
                    b[b.Length - 1] = r.FairPrice;
                    mr.FairPrice = (Boolean[])b.Clone();
                    if (!mr.PracticeFairPrice && r.FairPrice) { mr.PracticeFairPrice = r.FairPrice; }

//.........这里部分代码省略.........
开发者ID:reydavid47,项目名称:GITHUB,代码行数:101,代码来源:Handlers.cs

示例5: TSPFitness

 /// <summary>
 /// Konstruktor.
 /// </summary>
 /// <param name="costMatrix">Macierz kosztu przejścia.</param>
 public TSPFitness(Double[,] costMatrix)
 {
     this.costMatrix = (Double[,])costMatrix.Clone();
 }
开发者ID:rob86,项目名称:genetic-algorithms,代码行数:8,代码来源:TSPFitness.cs

示例6: ServiceHost_ClientInputRecieved

        public void ServiceHost_ClientInputRecieved(object sender, ClientInputMessage e)
        {
            Trace.WriteLine("ClientInputRecieved Recieved User Id : " + e.idUsuario, "Warning");
            try
            {
                /*Crear Blob desde un Stream*/
                // Se obtiene la cuenta de almacenamiento
                storageAccount = CloudStorageAccount.Parse(
                    CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Se crea el cliente de blobs
                blobClient = storageAccount.CreateCloudBlobClient();

                // Obtencion del container
                container = blobClient.GetContainerReference(VariablesConfiguracion.containerName);

                Int64 subid = 1;

                String mustacheTemplateStr = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/App_Data/mustacheCloud.txt");

                //Template para generar los MDL
                FormatCompiler compiler = new FormatCompiler();
                Generator generatorMDL = compiler.Compile(mustacheTemplateStr);

                //Obtener parametros del cliente
                SimulacionParameters parametros = JsonConvert.DeserializeObject<SimulacionParameters>(e.message);

                //Barrido paramétrico
                //Especificar número de parámetros, n
                Int32 n = parametros.reacciones.Count(r => r.rate != null);
                if (n > 0)
                {
                    //Inicializo vector de inicios, fines y steps
                    LinkedList<Double> inicios = new LinkedList<Double>();
                    LinkedList<Double> fines = new LinkedList<Double>();
                    LinkedList<Double> steps = new LinkedList<Double>();
                    foreach (var reaccion in parametros.reacciones.FindAll(r => r.rate != null))
                    {
                        var inicio = reaccion.rate.rateInicio;
                        var fin = reaccion.rate.rateFin;
                        var step = reaccion.rate.rateStep;
                        inicios.AddLast(inicio);
                        fines.AddLast(fin);
                        steps.AddLast(step);
                    }

                    var iniciosArray = inicios.ToArray();
                    var finesArray = fines.ToArray();
                    var stepsArray = steps.ToArray();

                    //Defino vector lógico L para hacer barrido selectivo
                    Int32[] vectorLogico = new Int32[n];
                    for (int i = 0; i < n; i++)
                    {
                        //vectorLogico[i] = i < 5 ? 1 : 100;
                        vectorLogico[i] = 1000;
                    }

                    // Inicialización del vector j
                    Double[] j = new Double[n];
                    for (var k = 0; k < n; k++)
                    {
                        if (k == vectorLogico[k])
                        {
                            iniciosArray[k] += stepsArray[k];
                        }
                        j[k] = iniciosArray[k];
                    }

                    LinkedList<Double[]> jotas = new LinkedList<double[]>();
                    //Barrido parametrico
                    Int32 z = n - 1;
                    while (z >= 0)
                    {
                        if ((j[z] - finesArray[z]) * stepsArray[z] > 0)
                        {
                            j[z] = iniciosArray[z];
                            z--;
                        }
                        else
                        {
                            jotas.AddLast((double[])j.Clone()); //Para ver las combinaciones que creo
                            var auxId = subid;
                            Thread thread = new Thread(() => CrearMDL(e, auxId, (double[])j.Clone(), parametros, generatorMDL));
                            thread.Start();
                            //CrearMDL(e, subid, (double[])j.Clone(), parametros, generatorMDL);
                            z = n - 1;
                            subid++;
                        }
                        if (z >= 0)
                        {
                            j[z] += stepsArray[z];
                            if (z == vectorLogico[z])
                            {
                                j[z] += stepsArray[z];
                            }
                        }
                    }

                }
//.........这里部分代码省略.........
开发者ID:lulimarroig,项目名称:CloudComputingEmbrionario,代码行数:101,代码来源:WorkerRole.cs


注:本文中的System.Double.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。