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


C# YAMP.ScalarValue类代码示例

本文整理汇总了C#中YAMP.ScalarValue的典型用法代码示例。如果您正苦于以下问题:C# ScalarValue类的具体用法?C# ScalarValue怎么用?C# ScalarValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScalarValue类属于YAMP命名空间,在下文中一共展示了ScalarValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Function

        public MatrixValue Function(MatrixValue M)
        {
            if (M.DimensionX != 3 && M.DimensionY != 3)
                throw new YAMPMatrixDimensionException(3, M.DimensionX, M.DimensionY, M.DimensionX);

            var isTransposed = M.DimensionY != 3;

            if (isTransposed)
            {
                M = M.Transpose();
            }

            var m = new MatrixValue(3, M.DimensionX);

            for (var i = 1; i <= M.DimensionX; i++)
            {
                var r = M[1, i].Re;
                var theta = M[2, i].Re;
                var phi = M[3, i].Re;
                var rt = r * Math.Sin(theta);
                m[1, i] = new ScalarValue(rt * Math.Cos(phi));
                m[2, i] = new ScalarValue(rt * Math.Sin(phi));
                m[3, i] = new ScalarValue(r * Math.Cos(theta));
            }

            return isTransposed ? m.Transpose() : m;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:27,代码来源:Sph2CartFunction.cs

示例2: cDot

        /// <summary>
        /// Returns the complex dot product (a, b).
        /// </summary>
        /// <param name="aStore">The first vector a.</param>
        /// <param name="aOffset">Offset in the vector a.</param>
        /// <param name="aStride">The offset between two elements of the vector a.</param>
        /// <param name="bStore">The second vector b.</param>
        /// <param name="bOffset">Offset in the vector a.</param>
        /// <param name="bStride">The offset between two elements of the vector a.</param>
        /// <param name="count">The number of elements to consider.</param>
        /// <returns>The result of the complex dot product.</returns>
        public static ScalarValue cDot(ScalarValue[] aStore, int aOffset, int aStride, ScalarValue[] bStore, int bOffset, int bStride, int count)
        {
            double re = 0.0;
            double im = 0.0;
            int n = 0;
            int a = aOffset;
            int b = bOffset;

            while (n < count)
            {
                var re1 = aStore[a].Re;
                var im1 = aStore[a].Im;
                var re2 = bStore[b].Re;
                var im2 = bStore[b].Im;

                re += (re1 * re2 - im1 * im2);
                im += (re1 * im2 + im1 * re2);

                n++;
                a += aStride;
                b += bStride;
            }

            return new ScalarValue(re, im);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:36,代码来源:BlasL1.cs

示例3: Ylm

 public static ScalarValue Ylm(int l, int m, double theta, double phi)
 {
     var expphi = new ScalarValue(0.0, m * phi).Exp();
     var factor = m < 0 ? Math.Pow(-1, -m) : 1.0;
     var legend = Plm(l, Math.Abs(m), Math.Cos(theta));
     return factor * expphi * legend;
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:7,代码来源:YlmFunction.cs

示例4: Function

        public BarPlotValue Function(MatrixValue Y, ScalarValue nbins)
        {
            var nn = nbins.GetIntegerOrThrowException("nbins", Name);
            var bp = new BarPlotValue();

            if (Y.IsVector)
            {
                bp.AddPoints(YMath.Histogram(Y, nn));
            }
            else
            {
                var M = new MatrixValue();

                for (var i = 1; i <= Y.DimensionX; i++)
                {
                    var N = YMath.Histogram(Y.GetColumnVector(i), nn);

                    for (var j = 1; j <= N.Length; j++)
                    {
                        M[j, i] = N[j];
                    }
                }

                bp.AddPoints(M);
            }

            return bp;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:28,代码来源:HistFunction.cs

示例5: Function

        public MatrixValue Function(MatrixValue x, MatrixValue y, ScalarValue n)
        {
            if (x.Length != y.Length)
                throw new YAMPDifferentLengthsException(x.Length, y.Length);

            var nn = n.GetIntegerOrThrowException("n", Name);
            var m = nn + 1;

            if (m < 2)
                throw new YAMPArgumentRangeException("n", 0.0);

            var M = new MatrixValue(x.Length, m);
            var b = new MatrixValue(x.Length, 1);

            for (var j = 1; j <= M.Rows; j++)
            {
                var el = ScalarValue.One;
                var z = x[j];

                for (var i = 1; i <= M.Columns; i++)
                {
                    M[j, i] = el;
                    el *= z;
                }

                b[j, 1] = y[j];
            }

            var qr = QRDecomposition.Create(M);
            return qr.Solve(b);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:31,代码来源:PolyfitFunction.cs

示例6: Generate

        static MatrixValue Generate(Int32 n, Int32 m)
        {
            var distribution = new DiscreteUniformDistribution(Rng);
            var l = n * m;
            var M = new MatrixValue(n, m);
            var numbers = new List<Int32>();
            distribution.Alpha = 0;

            for (var i = 1; i <= l; i++)
            {
                numbers.Add(i);
            }

            for (var j = 1; j <= n; j++)
            {
                for (var i = 1; i <= m; i++)
                {
                    distribution.Beta = numbers.Count - 1;
                    var index = distribution.Next();
                    index = Math.Max(Math.Min(0, index), numbers.Count - 1);
                    M[j, i] = new ScalarValue(numbers[index]);
                    numbers.RemoveAt(index);
                }
            }

            return M;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:27,代码来源:MagicFunction.cs

示例7: Function

        public ArgumentsValue Function(MatrixValue X, MatrixValue Y)
        {
            if (X.Length != Y.Length)
                throw new YAMPDifferentLengthsException(X.Length, Y.Length);

            var x1 = new ScalarValue();
            var y1 = new ScalarValue();
            var xy = new ScalarValue();
            var x2 = new ScalarValue();
            var slope = new ScalarValue();
            var offset = new ScalarValue();

            for (var i = 1; i <= X.Length; i++)
            {
                x1 = x1 + X[i];
                y1 = y1 + Y[i];
                xy = xy + X[i] * Y[i];
                x2 = x2 + X[i] * X[i];
            }

            var J = ((Double)X.Length * x2) - (x1 * x1);

            if (J.Re != 0.0)
            {
                slope = (((Double)X.Length * xy) - (x1 * y1)) / J.Re;
                offset = ((y1 * x2) - (x1 * xy)) / J.Re;
            }

            return new ArgumentsValue(slope, offset);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:30,代码来源:LsqFunction.cs

示例8: Function

 public MatrixValue Function(ScalarValue x0, ScalarValue xn, ScalarValue y0, ScalarValue yn, ScalarValue xsteps, ScalarValue ysteps)
 {
     var xs = xsteps.GetIntegerOrThrowException("xsteps", Name);
     var ys = ysteps.GetIntegerOrThrowException("ysteps", Name);
     var m = new Mandelbrot();
     return m.CalculateMatrix(x0.Re, xn.Re, y0.Re, yn.Re, xs, ys);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:7,代码来源:MandelbrotFunction.cs

示例9: Function

        public MatrixValue Function(ScalarValue j1, ScalarValue j2)
        {
            if (isNotHalf(j1))
                throw new ArgumentException("0, +-0.5, +-1, +-1.5, ...", j1.Re.ToString());

            if (isNotHalf(j2))
                throw new ArgumentException("0, +-0.5, +-1, +-1.5, ...", j2.Re.ToString());

            var l = 1;
            var M = new MatrixValue();

            for (var m1 = -j1.Re; m1 <= j1.Re; m1 += 1.0)
            {
                for (var m2 = -j2.Re; m2 <= j2.Re; m2 += 1.0)
                {
                    var m = m1 + m2;
                    var ja = j1.Re + j2.Re;

                    for (var j = Math.Abs(m); j <= ja; j += 1.0)
                    {
                        var v = CGCoefficients(j1.Re, j2.Re, j, m1, m2);
                        M[l, 1] = new ScalarValue(m);
                        M[l, 2] = new ScalarValue(m1);
                        M[l, 3] = new ScalarValue(m2);
                        M[l, 4] = new ScalarValue(j);
                        M[l, 5] = new ScalarValue(v);
                        l++;
                    }
                }
            }

            return M;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:33,代码来源:ClebschFunction.cs

示例10: Function

        public MatrixValue Function(MatrixValue M)
        {
            if (M.DimensionX != 2 && M.DimensionY != 2)
                throw new YAMPMatrixDimensionException(2, M.DimensionX, M.DimensionY, M.DimensionX);

            var isTransposed = M.DimensionY != 2;

            if (isTransposed)
            {
                M = M.Transpose();
            }

            var m = new MatrixValue(2, M.DimensionX);

            for (var i = 1; i <= M.DimensionX; i++)
            {
                var x = M[1, i].Re;
                var y = M[2, i].Re;
                var phi = Math.Atan2(y, x);
                var r = x == 0.0 ? y : (y == 0.0 ? x : x / Math.Cos(phi));
                m[1, i] = new ScalarValue(r * Math.Cos(phi));
                m[2, i] = new ScalarValue(r * Math.Sin(phi));
            }

            return isTransposed ? m.Transpose() : m;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:26,代码来源:Cart2PolFunction.cs

示例11: Function

        public MatrixValue Function(MatrixValue M)
        {
            if (M.DimensionX != 3 && M.DimensionY != 3)
                throw new YAMPMatrixDimensionException(3, M.DimensionX, M.DimensionY, M.DimensionX);

            var isTransposed = M.DimensionY != 3;

            if (isTransposed)
            {
                M = M.Transpose();
            }

            var m = new MatrixValue(3, M.DimensionX);

            for (var i = 1; i <= M.DimensionX; i++)
            {
                var x = M[1, i].Re;
                var y = M[2, i].Re;
                var z = M[3, i].Re;
                var r = Math.Sqrt(x * x + y * y + z * z);
                var phi = Math.Atan2(y, x);
                var theta = Math.Acos(z / r);
                m[1, i] = new ScalarValue(r);
                m[2, i] = new ScalarValue(theta);
                m[3, i] = new ScalarValue(phi);
            }

            return isTransposed ? m.Transpose() : m;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:29,代码来源:Cart2SphFunction.cs

示例12: Function

        public ArgumentsValue Function(ScalarValue n)
        {
            var nn = n.GetIntegerOrThrowException("n", Name);
            int dim = nn + 1;

            if (dim < 2)
                throw new YAMPArgumentRangeException("n", 1.0);

            var X = new MatrixValue(dim, dim); // x = sin(phi) * cos(theta)
            var Y = new MatrixValue(dim, dim); // y = sin(phi) * sin(theta)
            var Z = new MatrixValue(dim, dim); // z = cos(phi)

            var stheta = Table(0.0, 2.0 * Math.PI, dim, Math.Sin);
            var ctheta = Table(0.0, 2.0 * Math.PI, dim, Math.Cos);
            var sphi = Table(0.0, Math.PI, dim, Math.Sin);
            var cphi = Table(0.0, Math.PI, dim, Math.Cos);

            for (var j = 0; j < dim; j++)
            {
                var col = j + 1;

                for (var i = 0; i < dim; i++)
                {
                    var row = i + 1;

                    X[row, col] = new ScalarValue(sphi[j] * ctheta[i]);
                    Y[row, col] = new ScalarValue(sphi[j] * stheta[i]);
                    Z[row, col] = new ScalarValue(cphi[j]);
                }
            }

            return new ArgumentsValue(X, Y, Z);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:33,代码来源:SphereFunction.cs

示例13: Plot

        Plot2DValue Plot(IFunction f, Double minx, Double maxx, Double precision)
        {
            var cp = new Plot2DValue();
            var N = (Int32)((maxx - minx) / precision) + 1;
            var M = new MatrixValue(N, 2);
            var x = new ScalarValue(minx);

            for (var i = 0; i < N; i++)
            {
                var row = i + 1;
                var y = f.Perform(Context, x);
                M[row, 1] = x.Clone();

                if (y is ScalarValue)
                {
                    M[row, 2] = (ScalarValue)y;
                }
                else if (y is MatrixValue)
                {
                    var Y = (MatrixValue)y;

                    for (var j = 1; j <= Y.Length; j++)
                    {
                        M[row, j + 1] = Y[j];
                    }
                }

                x.Re += precision;
            }

            cp.AddPoints(M);
            return cp;
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:33,代码来源:FplotFunction.cs

示例14: FftPass

        public virtual void FftPass(ScalarValue[] x, ScalarValue[] y, int Ns, int sign)
        {
            var v = new ScalarValue[R];
            int dx = N / R;

            for (int j = 0; j < dx; j++)
            {
                int xi = j;
                int ui = 0;

                if (sign < 0)
                    ui = N;

                int du = (dx / Ns) * (j % Ns);

                if (sign < 0)
                    du = -du;

                v[0] = x[xi];

                for (int r = 1; r < R; r++)
                {
                    xi += dx;
                    ui += du;
                    v[r] = x[xi] * u[ui];
                }

                int y0 = Expand(j, Ns, R);
                FftKernel(v, y, y0, Ns, sign);
            }
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:31,代码来源:Transformlet.cs

示例15: Function

 public MatrixValue Function(ScalarValue x0, ScalarValue xn, ScalarValue y0, ScalarValue yn)
 {
     var m = new Newton();
     var xsteps = (int)Math.Abs(Math.Ceiling((xn.Re - x0.Re) / 0.1));
     var ysteps = (int)Math.Abs(Math.Ceiling((yn.Re - y0.Re) / 0.1));
     return m.CalculateMatrix(x0.Re, xn.Re, y0.Re, yn.Re, xsteps, ysteps);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:7,代码来源:NewtonFunction.cs


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