示例#1
0
 public Plot2DValue Function(MatrixValue m, MatrixValue n)
 {
     var plot = new Plot2DValue();
     plot.AddPoints(m, n);
     plot.IsLogX = true;
     return plot;
 }
示例#2
0
 public ContourPlotValue Function(MatrixValue X, MatrixValue Y, MatrixValue Z, MatrixValue v)
 {
     var plot = new ContourPlotValue();
     plot.AddPoints(X, Y, Z);
     plot.SetLevels(v);
     return plot;
 }
示例#3
0
        public MatrixValue Function(FunctionValue f, ScalarValue n, ScalarValue dt, ArgumentsValue args)
        {
            var numberOfMeasurements = (Int32)n.Value;
            var timeBetweenMeasurements = (Int32)Math.Floor(dt.Value * 1000);
            var results = new MatrixValue(numberOfMeasurements, 2);
            var time = 0.0;

            for (var i = 1; i <= numberOfMeasurements; i++)
            {
                Thread.Sleep(timeBetweenMeasurements);

                var result = f.Perform(context, args);
                results[i, 1] = new ScalarValue(time);

                if (result is ScalarValue)
                {
                    results[i, 2] = result as ScalarValue;
                }
                else if (result is MatrixValue)
                {
                    var m = result as MatrixValue;

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

                time += dt.Value;
            }

            return results;
        }
示例#4
0
 public MatrixValue Function(MatrixValue M)
 {
     var m = new MatrixValue();
     m[1, 1] = new ScalarValue(M.DimensionY);
     m[1, 2] = new ScalarValue(M.DimensionX);
     return m;
 }
示例#5
0
 public MatrixValue Function(ScalarValue x)
 {
     var m = new MatrixValue();
     m[1, 1] = new ScalarValue(1);
     m[1, 2] = new ScalarValue(1);
     return m;
 }
示例#6
0
        public ArgumentsValue Function(MatrixValue x, MatrixValue y)
        {
            var M = x.Length;
            var N = y.Length;
            var X = new MatrixValue(N, M);
            var Y = new MatrixValue(N, M);

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

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

            return new ArgumentsValue(X, Y);
        }
示例#7
0
 public MatrixValue Function(StringValue str)
 {
     var m = new MatrixValue();
     m[1, 1] = new ScalarValue(1);
     m[1, 2] = new ScalarValue(str.Value.Length);
     return m;
 }
示例#8
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="samples">The given sample values - the matrix has to be Nx2 with the
        /// first column for the x values and the second column for the y values.</param>
        public Interpolation(MatrixValue samples)
        {
            _samples = samples;
            np = samples.DimensionY;

            if (samples.DimensionX != 2)
                new YAMPMatrixDimensionException(samples.DimensionY, 2, samples.DimensionY, samples.DimensionX);
        }
示例#9
0
 public ContourPlotValue Function(MatrixValue X, MatrixValue Y, MatrixValue Z, ScalarValue n)
 {
     var nn = n.GetIntegerOrThrowException("n", Name);
     var plot = new ContourPlotValue();
     plot.AddPoints(X, Y, Z);
     plot.SetLevels(nn);
     return plot;
 }
示例#10
0
 public ArgumentsValue Function(ScalarValue Coarsening)
 {
     var result = _sensor.Capture(Coarsening.Value).Result;
     var red = new MatrixValue(result.Red);
     var green = new MatrixValue(result.Green);
     var blue = new MatrixValue(result.Blue);
     return new ArgumentsValue(red, green, blue);
 }
示例#11
0
 public SurfacePlotValue Function(MatrixValue X, MatrixValue Y, MatrixValue Z)
 {
     var splot = new SurfacePlotValue();
     splot.AddPoints(X, Y, Z);
     splot.IsMesh = true;
     splot.IsSurf = false;
     return splot;
 }
示例#12
0
文件: Base.cs 项目: FlorianRappl/YAMP
 protected void TestValue(String query, MatrixValue result)
 {
     var parser = new Parser();
     parser.LoadPlugin(typeof(SetsPlugin).Assembly);
     parser.UseScripting = true;
     var value = parser.Evaluate(query);
     var mat = ((MatrixValue)value);
     Assert.AreEqual(result, mat);
 }
示例#13
0
        /// <summary>
        /// Creates the class for a GMRES(k) solver.
        /// </summary>
        /// <param name="A">The matrix A to consider as system of linear equations.</param>
        /// <param name="restart">Should restarts be executed?</param>
        public GMRESkSolver(MatrixValue A, bool restart)
            : base(A)
        {
            MaxIterations = A.Length;

            if(restart)
                Restart = MaxIterations / 10;
            else //No Restart
                Restart = MaxIterations;
        }
示例#14
0
        /// <summary>
        /// Uses the abstract Compute() methods to compute ALL values.
        /// </summary>
        /// <param name="x">The matrix with given x values.</param>
        /// <returns>The interpolated y values.</returns>
        public virtual MatrixValue ComputeValues(MatrixValue x)
        {
            var y = new MatrixValue(x.DimensionY, x.DimensionX);

            for (var i = 1; i <= x.DimensionX; i++)
                for (var j = 1; j <= x.DimensionY; j++)
                    y[j, i].Re = ComputeValue(x[j, i].Re);

            return y;
        }
示例#15
0
        static ScalarValue GetVectorSum(MatrixValue vec)
        {
            var sum = ScalarValue.Zero;

            for (var i = 1; i <= vec.Length; i++)
            {
                sum = sum + vec[i];
            }

            return sum;
        }
示例#16
0
        static ScalarValue GetVectorProduct(MatrixValue vec)
        {
            var prod = ScalarValue.One;

            for (var i = 1; i <= vec.Length; i++)
            {
                prod = prod * vec[i];
            }

            return prod;
        }
示例#17
0
        MatrixValue GetVectorProd(MatrixValue vec)
        {
            var m = new MatrixValue(vec.DimensionY, vec.DimensionX);
            var prod = ScalarValue.One;

            for (var i = 1; i <= vec.Length; i++)
            {
                prod *= vec[i];
                m[i] = prod;
            }

            return m;
        }
示例#18
0
        static MatrixValue GetVectorSum(MatrixValue vec)
        {
            var m = new MatrixValue(vec.DimensionY, vec.DimensionX);
            var sum = ScalarValue.Zero;

            for (var i = 1; i <= vec.Length; i++)
            {
                sum += vec[i];
                m[i] = sum;
            }

            return m;
        }
示例#19
0
        public static MatrixValue Mod(MatrixValue numerator, ScalarValue denominator)
        {
            var m = new MatrixValue(numerator.DimensionY, numerator.DimensionX);

            for (var i = 1; i <= numerator.DimensionX; i++)
            {
                for (var j = 1; j <= numerator.DimensionY; j++)
                {
                    m[j, i] = numerator[j, i] % denominator;
                }
            }

            return m;
        }
示例#20
0
        public MatrixValue Function(MatrixValue func)
        {
            var adm = new MatrixValue(func.DimensionY, func.DimensionX - 1);

            for (var i = 1; i <= func.DimensionY; i++)
            {
                for (var t = 1; t <= func.DimensionX - 1; t++)
                {
                    adm[i, t] = new ScalarValue(func[i, t + 1].Re - func[i, t].Re);
                }
            }

            return adm;
        }
示例#21
0
        public MatrixValue Function(MatrixValue M)
        {
            var v = new MatrixValue(M.Length, 1);
            var k = 1;

            for (var i = 1; i <= M.DimensionX; i++)
            {
                for (var j = 1; j <= M.DimensionY; j++)
                {
                    v[k++] = M[j, i];
                }
            }

            return v;
        }
示例#22
0
        public MatrixValue Function(ScalarValue n, ScalarValue alpha, MatrixValue Z)
        {
            var nn = n.GetIntegerOrThrowException("n", Name);
            var M = new MatrixValue(Z.DimensionY, Z.DimensionX);

            for (var i = 1; i <= Z.DimensionX; i++)
            {
                for (var j = 1; j <= Z.DimensionY; j++)
                {
                    M[j, i] = Gegenbauer(nn, alpha.Re, Z[j, i]);
                }
            }

            return M;
        }
示例#23
0
        /// <summary>
        /// Performs the integration.
        /// </summary>
        /// <param name="x">The x values.</param>
        /// <returns>The result of the integration.</returns>
        public override ScalarValue Integrate(MatrixValue x)
        {
            var y = Values;

            if (x.Length != y.Length)
                throw new YAMPDifferentLengthsException(x.Length, y.Length);

            var sum = 0.0;

            for (var i = 1; i < N - 1; i += 2)
            {
                sum += (x[i + 2].Re - x[i].Re) * (y[i].Re + 4.0 * y[i + 1].Re + y[i + 2].Re);
            }

            return new ScalarValue(sum / 6.0);
        }
示例#24
0
        public MatrixValue Function(ScalarValue n, ScalarValue m, MatrixValue Z)
        {
            var nn = n.GetIntegerOrThrowException("n", Name);
            var nm = m.GetIntegerOrThrowException("m", Name);
            var M = new MatrixValue(Z.DimensionY, Z.DimensionX);

            for (var i = 1; i <= Z.DimensionX; i++)
            {
                for (var j = 1; j <= Z.DimensionY; j++)
                {
                    M[j, i] = Zernike(nn, nm, Z[j, i]);
                }
            }

            return M;
        }
示例#25
0
        public MatrixValue Function(MatrixValue Z, MatrixValue N)
        {
            if (Z.DimensionY != N.DimensionY || Z.DimensionX != N.DimensionX)
                throw new YAMPDifferentDimensionsException(Z, N);

            var M = new MatrixValue(Z.DimensionY, Z.DimensionX);

            for (var i = 1; i <= M.DimensionX; i++)
            {
                for (var j = 1; j <= M.DimensionY; j++)
                {
                    M[j, i] = Gamma.LinearGamma(Z[j, i] + N[j, i]) / Gamma.LinearGamma(Z[j, i]);
                }
            }

            return M;
        }
示例#26
0
文件: FFT.cs 项目: FlorianRappl/YAMP
        MatrixValue fft(MatrixValue x)
        {
            var length = x.Length;

            if (length == 1)
            {
                return x.Clone();
            }

            // Cooley-Tukey FFT
            if (length % 2 != 0)
                throw new YAMPDifferentLengthsException(length, "2^n");

            // even fft
            var even = new MatrixValue(length / 2, 1);

            for (var k = 1; k <= even.Length; k++)
            {
                even[k] = x[2 * k];
            }

            var q = fft(even);

            // odd fft;
            var odd = even;

            for (var k = 1; k <= odd.Length; k++)
            {
                odd[k] = x[2 * k - 1];
            }

            var r = fft(odd);

            // combine
            var y = new MatrixValue(length, 1);

            for (var k = 1; k <= odd.Length; k++)
            {
                var value = -2 * (k - 1) * Math.PI / length;
                var wk = new ScalarValue(Math.Cos(value), Math.Sin(value));
                y[k] = q[k] + (wk * r[k]);
                y[k + odd.Length] = q[k] - (wk * r[k]);
            }

            return y;
        }
        /// <summary>
        /// Creates a new householder decomposition.
        /// </summary>
        /// <param name="A">The matrix to decompose.</param>
        public HouseholderDecomposition(MatrixValue A)
            : base(A)
        {
            QR = A.GetComplexMatrix();
            Rdiag = new ScalarValue[n];

            // Main loop.
            for (int k = 0; k < n; k++)
            {
                var nrm = 0.0;

                for (int i = k; i < m; i++)
                    nrm = Helpers.Hypot(nrm, QR[i][k].Re);

                if (nrm != 0.0)
                {
                    // Form k-th Householder vector.

                    if (QR[k][k].Re < 0)
                        nrm = -nrm;

                    for (int i = k; i < m; i++)
                        QR[i][k] /= nrm;

                    QR[k][k] += ScalarValue.One;

                    // Apply transformation to remaining columns.
                    for (int j = k + 1; j < n; j++)
                    {
                        var s = ScalarValue.Zero;

                        for (int i = k; i < m; i++)
                            s += QR[i][k] * QR[i][j];

                        s = (-s) / QR[k][k];

                        for (int i = k; i < m; i++)
                            QR[i][j] += s * QR[i][k];
                    }
                }
                else
                    FullRank = false;

                Rdiag[k] = new ScalarValue(-nrm);
            }
        }
示例#28
0
        public MatrixValue Function(MatrixValue M)
        {
            if (!M.IsVector)
            {
                var result = new MatrixValue();

                for (var i = 0; i < M.DimensionY; i++)
                {
                    var vec = M.GetSubMatrix(i, i + 1, 0, M.DimensionX);
                    vec = vec.VectorSort();
                    result = result.AddRow(vec);
                }

                return result;
            }

            return M.VectorSort();
        }
示例#29
0
        public MatrixValue Function(MatrixValue A, MatrixValue B)
        {
            //TODO: Additional options like ( http://www.mathworks.de/de/help/matlab/ref/convn.html )
            //i.e. "full" (default - it is this), "same" (only same length), "valid" (see formula on the website)
            var result = new MatrixValue(A.Length + B.Length - 1, 1);

            for (var i = 1; i <= A.Length; i++)
            {
                var k = i;

                for (var j = 1; j <= B.Length; j++)
                {
                    result[k++] += A[i] * B[j];
                }
            }

            return result;
        }
示例#30
0
        public ArgumentsValue Function(MatrixValue M)
        {
            var rvalues = new MatrixValue(M.DimensionY, M.DimensionX);
            var gvalues = new MatrixValue(M.DimensionY, M.DimensionX);
            var bvalues = new MatrixValue(M.DimensionY, M.DimensionX);

            for (var i = 1; i <= M.DimensionY; i++)
            {
                for (var j = 1; j <= M.DimensionX; j++)
                {
                    int value = M[i, j].IntValue;

                    rvalues[i, j] = new ScalarValue((value / rfactor) % 256);
                    gvalues[i, j] = new ScalarValue((value / gfactor) % 256);
                    bvalues[i, j] = new ScalarValue((value / bfactor) % 256);
                }
            }

            return new ArgumentsValue(rvalues, gvalues, bvalues);
        }
示例#31
0
 public MatrixValue Function(MatrixValue M)
 {
     return(GetIndices(M, M.Length, 0));
 }
示例#32
0
 public MatrixValue Function(MatrixValue M, ScalarValue n, ScalarValue sigma)
 {
     return(GetIndices(M, n.GetIntegerOrThrowException("n", Name), sigma.GetIntegerOrThrowException("sigma", Name)));
 }
示例#33
0
 public MatrixValue Function(MatrixValue M, ScalarValue n)
 {
     return(GetIndices(M, n.GetIntegerOrThrowException("n", Name), 0));
 }
 public override MatrixValue Function(MatrixValue x)
 {
     return(base.Function(x));
 }
示例#35
0
        public ArgumentsValue Function(MatrixValue M)
        {
            var qr = QRDecomposition.Create(M);

            return(new ArgumentsValue(qr.Q, qr.R));
        }
 public MatrixValue Function()
 {
     return(MatrixValue.One(1));
 }
示例#37
0
        public MatrixValue Function(MatrixValue cfgs, ScalarValue n, FunctionValue f, ArgumentsValue P)
        {
            var numberOfBlocks = n.GetIntegerOrThrowException("n", Name);
            var nConfigs       = cfgs.DimensionY;
            var nData          = cfgs.DimensionX;

            if (numberOfBlocks > nConfigs)
            {
                throw new YAMPException("Jackknife: The number of measurements n is greater than the number of configurations cfgs!");
            }

            if (numberOfBlocks <= 1)
            {
                throw new YAMPException("Jackknife: The number of measurements n <= 1!");
            }

            var parameters = new ArgumentsValue(cfgs);

            foreach (var m in P.Values)
            {
                parameters.Insert(m);
            }

            var temp = f.Perform(Context, parameters);
            int nResult;//dimension of the result

            if (temp is ScalarValue)
            {
                nResult = 1;
            }
            else if (temp is MatrixValue)
            {
                nResult = (temp as MatrixValue).Length;
            }
            else
            {
                throw new YAMPException("Jackknife: Observable f has to return either a scalar or a matrix!");
            }

            var JackknifeObservable = new MatrixValue(numberOfBlocks, nResult);
            var BlockSize           = nConfigs / numberOfBlocks;
            var nConfigsBlocked     = BlockSize * numberOfBlocks;
            var residualConfigs     = nConfigs - nConfigsBlocked;

            for (int i = 1; i <= numberOfBlocks; i++)
            {
                if (i <= numberOfBlocks - residualConfigs)
                {
                    //the first (NumberOfBlocks - residualConfigs) blocks discard (BlockSize) elements ...
                    var JackknifeConfigs = new MatrixValue(nConfigs - BlockSize, nData);
                    int j = 1;

                    for (; j <= (i - 1) * BlockSize; j++)
                    {
                        for (int k = 1; k <= nData; k++)
                        {
                            JackknifeConfigs[j, k] = cfgs[j, k];
                        }
                    }

                    j += BlockSize;

                    for (; j <= nConfigs; j++)
                    {
                        for (int k = 1; k <= nData; k++)
                        {
                            JackknifeConfigs[j - BlockSize, k] = cfgs[j, k];
                        }
                    }

                    parameters = new ArgumentsValue(JackknifeConfigs);
                }
                else
                {
                    //... whereas the residual (residualConfigs) blocks discard (BlockSize + 1) elements
                    var JackknifeConfigs = new MatrixValue(nConfigs - BlockSize - 1, nData);
                    int j = 1;

                    for (; j <= nConfigs - (numberOfBlocks - (i - 1)) * (BlockSize + 1); j++)
                    {
                        for (int k = 1; k <= nData; k++)
                        {
                            JackknifeConfigs[j, k] = cfgs[j, k];
                        }
                    }

                    j += BlockSize + 1;

                    for (; j <= nConfigs; j++)
                    {
                        for (int k = 1; k <= nData; k++)
                        {
                            JackknifeConfigs[j - BlockSize - 1, k] = cfgs[j, k];
                        }
                    }

                    parameters = new ArgumentsValue(JackknifeConfigs);
                }

                foreach (var m in P.Values)
                {
                    parameters.Insert(m);
                }

                temp = f.Perform(Context, parameters);

                if (temp is ScalarValue)
                {
                    JackknifeObservable[i] = (ScalarValue)temp;
                }
                else
                {
                    var T = (MatrixValue)temp;

                    for (int k = 1; k <= nResult; k++)
                    {
                        JackknifeObservable[i, k] = T[k];
                    }
                }
            }

            temp = YMath.Average(JackknifeObservable);

            for (int i = 1; i <= numberOfBlocks; i++)
            {
                if (temp is ScalarValue)
                {
                    JackknifeObservable[i] -= temp as ScalarValue;
                    JackknifeObservable[i] *= JackknifeObservable[i];
                }
                else
                {
                    var m = (MatrixValue)temp;

                    for (int k = 1; k <= nResult; k++)
                    {
                        JackknifeObservable[i, k] -= m[k];
                        JackknifeObservable[i, k] *= JackknifeObservable[i, k];
                    }
                }
            }

            var error = YMath.Average(JackknifeObservable);
            var scale = numberOfBlocks - 1.0;

            if (error is ScalarValue)
            {
                error = ((ScalarValue)error) * scale;
            }
            else
            {
                var e = (MatrixValue)error;

                for (var i = 1; i <= e.DimensionY; i++)
                {
                    for (int j = 1; j <= e.DimensionX; j++)
                    {
                        e[i, j] *= scale;
                    }
                }
            }

            var sqrt = new SqrtFunction();

            error = sqrt.Perform(error);
            var result = new MatrixValue(2, nResult);

            if (temp is ScalarValue)
            {
                result[1] = (ScalarValue)temp;
                result[2] = (ScalarValue)error;
            }
            else
            {
                var T = (MatrixValue)temp;
                var E = (MatrixValue)error;

                for (int k = 1; k <= nResult; k++)
                {
                    result[1, k] = T[k];
                    result[2, k] = E[k];
                }
            }

            return(result);
        }
 public MatrixValue(MatrixValue v)
 {
     Route      = v.Route;
     _value     = v._value;
     IsInfinity = v.IsInfinity;
 }
示例#39
0
        public ContourPlotValue Function(MatrixValue X, MatrixValue Y, MatrixValue Z, MatrixValue v)
        {
            var plot = new ContourPlotValue();

            plot.AddPoints(X, Y, Z);
            plot.SetLevels(v);
            return(plot);
        }
示例#40
0
        public MatrixValue Function(MatrixValue A, MatrixValue b)
        {
            var gmres = new GMRESkSolver(A);

            return(gmres.Solve(b));
        }
示例#41
0
 /// <summary>
 /// Adds points to the plot.
 /// </summary>
 /// <param name="m">The given matrix.</param>
 public abstract void AddPoints(MatrixValue m);
        private void InitMatrix()
        {
            MatrixValue matrix = (MatrixValue)_currentQuestionEntity.Question;

            if (QuestionMatrix.Children.Count == 0)
            {
                for (int i = 0; i < matrix.Matrix.Length + 1; i++)
                {
                    QuestionMatrix.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });
                    QuestionMatrix.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                }
            }
            else
            {
                _textAnswer.Clear();
                QuestionMatrix.Children.Clear();
            }

            for (int i = 0; i < matrix.Matrix.Length; i++)
            {
                for (int j = 0; j < matrix.Matrix[i].Length; j++)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.IsEnabled = false;
                    textBlock.Margin    = new Thickness(3);
                    textBlock.FontSize  = 12;
                    textBlock.Text      = matrix.Matrix[i][j];
                    QuestionMatrix.Children.Add(textBlock);
                    Grid.SetRow(textBlock, i);
                    Grid.SetColumn(textBlock, j);
                }
            }

            for (int i = 0; i < matrix.Matrix.Length + 1; i++)
            {
                for (int j = 0; j < matrix.Matrix.Length + 1; j++)
                {
                    if (_currentQuestionEntity.CodeType == CodeType.Encoding)
                    {
                        if (i != j && (matrix.Matrix.Length == i) && matrix.Matrix[0].Length != j)
                        {
                            TextBox textBlock = new TextBox();

                            textBlock.Margin   = new Thickness(3);
                            textBlock.FontSize = 12;
                            textBlock.Text     = "0";
                            QuestionMatrix.Children.Add(textBlock);
                            _textAnswer.Add(textBlock);
                            Grid.SetRow(textBlock, i);
                            Grid.SetColumn(textBlock, j);
                        }
                    }
                    else
                    {
                        if (i != j && (matrix.Matrix[0].Length == j) && (matrix.Matrix.Length != i))
                        {
                            TextBox textBlock = new TextBox();

                            textBlock.Margin   = new Thickness(5);
                            textBlock.FontSize = 17;
                            textBlock.Text     = "0";
                            QuestionMatrix.Children.Add(textBlock);
                            _textAnswer.Add(textBlock);
                            Grid.SetRow(textBlock, i);
                            Grid.SetColumn(textBlock, j);
                        }
                    }
                }
            }
        }
        private void StaertTest_Click(object sender, RoutedEventArgs e)
        {
            MatrixValue matrix = (MatrixValue)_currentQuestionEntity.Question;


            string[][] answer = null;

            if (_currentQuestionEntity.CodeType == CodeType.Encoding)
            {
                try
                {
                    answer    = new string[1][];
                    answer[1] = new string[_textAnswer.Count];
                    for (int i = 0; i < _textAnswer.Count; i++)
                    {
                        answer[1][i] = _textAnswer[i].Text;
                    }
                }
                catch { }
            }
            else
            {
                try
                {
                    answer = new string[_textAnswer.Count][];

                    for (int i = 0; i < _textAnswer.Count; i++)
                    {
                        answer[i]    = new string[1];
                        answer[i][1] = _textAnswer[i].Text;
                    }
                }
                catch { }
            }

            StateType stateType = _answerCheker.CheckQuestion(new TestAnswerEntity()
            {
                AllCount = _questionEntities.Count,
                Answer   = new MatrixValue()
                {
                    Matrix = answer
                },
                CurrentCount   = number,
                NameTest       = QuestionType.RidaMallera.ToString(),
                QuestionEntity = _currentQuestionEntity
            }).Data;

            _currentQuestionEntity = _questionEntities
                                     .FirstOrDefault(p => p.StateType == StateType.Default);

            if (_currentQuestionEntity != null)
            {
                InitMatrix();
                DescriptionText.Text = _currentQuestionEntity?.Description;

                number++;
                Number.Text  = number.ToString();
                Correct.Text = $"{_questionEntities.Count(p => p.StateType == StateType.Corect)}/{_questionEntities.Count}";
            }
            else
            {
                _grid.Children.Clear();
                _grid.Children.Add(new ResultView(_grid, this));
            }
        }
        public ArgumentsValue Function(MatrixValue M)
        {
            var svd = new SingularValueDecomposition(M);

            return(new ArgumentsValue(svd.S, svd.GetU(), svd.GetV()));
        }
示例#45
0
 /// <summary>
 /// A complex plot cannot have any points assigned. You have to
 /// assign a function instead.
 /// </summary>
 /// <param name="m">Useless.</param>
 public override void AddPoints(MatrixValue m)
 {
     //Leave empty
 }
 public MatrixValue Function(MatrixValue Z)
 {
     return(Function(Z, new ScalarValue(Math.E)));
 }
        public MatrixValue Function(ScalarValue dim)
        {
            var n = dim.GetIntegerOrThrowException("dim", Name);

            return(MatrixValue.One(n));
        }
示例#48
0
        public ScalarValue Function(MatrixValue y, MatrixValue x)
        {
            var integral = new SimpsonIntegrator(y);

            return(integral.Integrate(x));
        }
示例#49
0
 public BarPlotValue Function(MatrixValue Y)
 {
     return(Function(Y, new ScalarValue(10)));
 }
示例#50
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="A">The matrix A for which to solve.</param>
 public CGSolver(MatrixValue A) : base(A)
 {
 }
示例#51
0
        /// <summary>
        /// Sets the z values given in the matrix m with the corresponding x and y values.
        /// </summary>
        /// <param name="x">The matrix with the x values.</param>
        /// <param name="y">The matrix with the y values.</param>
        /// <param name="z">The matrix with the function values / z values.</param>
        public void AddPoints(MatrixValue x, MatrixValue y, MatrixValue z)
        {
            data.Clear();

            if (x.Length > 0)
            {
                MinX = x[1, 1].Re;
                MaxX = x[1, 1].Re;
            }
            else
            {
                MinX = 0;
                MaxX = 0;
            }

            if (y.Length > 0)
            {
                MinY = y[1, 1].Re;
                MaxY = y[1, 1].Re;
            }
            else
            {
                MinY = 0;
                MaxY = 0;
            }

            if (z.Length > 0)
            {
                MinZ = z[1, 1].Re;
                MaxZ = z[1, 1].Re;
            }
            else
            {
                MinZ = 0;
                MaxZ = 0;
            }

            if (x.IsVector && y.IsVector)
            {
                var cols = Math.Min(x.Length, z.Columns);
                var rows = Math.Min(y.Length, z.Rows);
                Nx = cols;
                Ny = rows;

                for (var j = 1; j <= rows; j++)
                {
                    for (var i = 1; i <= cols; i++)
                    {
                        var v = new Vertex
                        {
                            X = x[i].Re,
                            Y = y[j].Re,
                            Z = z[j, i].Re
                        };
                        data.Add(v);

                        MinX = Math.Min(MinX, v.X);
                        MaxX = Math.Max(MaxX, v.X);
                        MinY = Math.Min(MinY, v.Y);
                        MaxY = Math.Max(MaxY, v.Y);
                        MinZ = Math.Min(MinZ, v.Z);
                        MaxZ = Math.Max(MaxZ, v.Z);
                    }
                }
            }
            else
            {
                var cols = Math.Min(x.Columns, Math.Min(y.Columns, z.Columns));
                var rows = Math.Min(x.Rows, Math.Min(y.Rows, z.Rows));
                Nx = cols;
                Ny = rows;

                for (var j = 1; j <= rows; j++)
                {
                    for (var i = 1; i <= cols; i++)
                    {
                        var v = new Vertex
                        {
                            X = x[j, i].Re,
                            Y = y[j, i].Re,
                            Z = z[j, i].Re
                        };
                        data.Add(v);

                        MinX = Math.Min(MinX, v.X);
                        MaxX = Math.Max(MaxX, v.X);
                        MinY = Math.Min(MinY, v.Y);
                        MaxY = Math.Max(MaxY, v.Y);
                        MinZ = Math.Min(MinZ, v.Z);
                        MaxZ = Math.Max(MaxZ, v.Z);
                    }
                }
            }
        }
示例#52
0
 public MatrixValue Function(MatrixValue cfgs, ScalarValue n, FunctionValue f)
 {
     return(Function(cfgs, n, f, new ArgumentsValue()));
 }