Ejemplo n.º 1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="NumericMatrixFactor" /> class.
    /// </summary>
    /// <param name="group">if set to <see langword="true" /> [group].</param>
    /// <param name="groupingStyle">The grouping style.</param>
    /// <param name="items">The items.</param>
    /// <param name="editableCells">if set to <see langword="true" /> [editable cells].</param>
    /// <param name="exponent">The exponent.</param>
    /// <param name="sequence">The sequence.</param>
    /// <param name="editable">if set to <see langword="true" /> [editable].</param>
    public NumericMatrixFactor(bool group, BarStyles groupingStyle, double[,] items, bool editableCells = false, IExpression?exponent = null, INumeric?sequence = null, bool editable = false)
    {
        _ = exponent;
        _ = sequence;

        Parent  = null;
        NumRows = items.GetLength(0);
        NumCols = items.GetLength(1);
        //UniformRowSize = true;
        //UniformColSize = true;
        Group         = group;
        GroupingStyle = groupingStyle;

        Items = new NumericFactor[NumRows, NumCols];
        for (var row = 0; row < NumRows; row++)
        {
            for (var col = 0; col < NumCols; col++)
            {
                Items[row, col] = new NumericFactor(items[row, col]);
                if (Items[row, col] is IExpression c)
                {
                    c.Parent   = this;
                    c.Editable = editableCells;
                }
            }
        }

        Editable = editable;
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Scales the equation factory.
    /// </summary>
    /// <param name="scalar">The scalar.</param>
    /// <param name="matrix">The matrix2.</param>
    /// <param name="matrixResult">The matrix result.</param>
    /// <returns></returns>
    public static RelationalOperation ScaleEquationFactory(NumericFactor scalar, NumericMatrixFactor matrix, out NumericMatrixFactor matrixResult)
    {
        var values1 = scalar.Value;
        var values2 = matrix.Coefficients;
        var values3 = Operations.Scale(values1, values2);

        matrixResult = new NumericMatrixFactor(values3, false);
        var equation = new RelationalOperation(
            ComparisonOperators.Equals,
            new NomialExpression(
                new ProductTerm(scalar, matrix)
                ),
            new ProductTerm(new NumericFactor(1), matrixResult)
            );

        return(equation);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Form1"/> class.
    /// </summary>
    public Form1()
    {
        InitializeComponent();

        //canvasControl.Font = new Font("Cambria Math", 12);
        canvasControl.BackColor = Color.White;
        //matrixGrid1.RenderBoundaries = true;

        numericOperand1   = new NumericFactor(ConstantFactors.Two);
        numericOperand2   = new NumericFactor(ConstantFactors.NegativeOne);
        numericResultand  = default;
        fractionOperand1  = new FractionFactor(ConstantFactors.OneHalf);
        fractionOperand2  = new FractionFactor(ConstantFactors.NegativeOneHalf);
        fractionResultand = default;
        //matrixOperand1 = new NumericMatrixFactor(new double[,] {
        //    { 11, 12, 13, },
        //    { 21, 22, 23, },
        //    { 31, 32, 33 }
        //}, true);
        matrixOperand1 = new NumericMatrixFactor(new double[, ] {
            { 4, 12, -16, },
            { 12, 37, -43, },
            { -16, -43, 98 }
        }, true);
        //matrixOperand2 = new NumericMatrixFactor(new double[,] {
        //    { 1, 0, 0, },
        //    { 0, 1, 0, },
        //    { 0, 0, 1 }
        //}, true);
        matrixOperand2 = new NumericMatrixFactor(new double[, ] {
            { 2, 0, 0, },
            { 6, 1, 0, },
            { -8, 5, 3 }
        }, true);
        //matrixOperand2 = new NumericMatrixFactor(new double[,] {
        //    { 11, 12, 13, },
        //    { 21, 22, 23, },
        //    { 31, 32, 33 }
        //}, true);

        listBox1.Items.AddRange(new object[] {
            "AdditionEquationFactory",
            "SubtractionEquationFactory",
            "ProductEquationFactory",
            "QuotientEquationFactory",
            "ScaleEquationFactory",
            "FractionScaleEquationFactory",
            //"LogarithmEquationFactory",
            //"SquareRootEquationFactory",
            //"CubeRootEquationFactory",
            "SquareEquationFactory",
            "CubeEquationFactory",
            "InverseEquationFactory",
            "RotateMatrixClockwiseFactory",
            "RotateMatrixCounterClockwiseFactory",
            "TransposeMatrixEquationFactory",
            "CholeskySolve"
        });

        expression             = () => new RelationalOperation(ComparisonOperators.Equals, null, null);
        canvasControl.AutoSize = true;
        canvasControl.Focus();

        _ = numericOperand2;
        _ = numericResultand;
        _ = fractionOperand2;
        _ = fractionResultand;
        _ = matrixResultand;
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NumericFactor"/> class.
 /// </summary>
 /// <param name="factor">The factor.</param>
 /// <param name="exponent">The exponent.</param>
 /// <param name="sequence">The sequence.</param>
 /// <param name="editable">The editable.</param>
 public NumericFactor(NumericFactor factor, IExpression?exponent = null, INumeric?sequence = null, bool?editable = null)
     : this(factor.Value, exponent ?? factor.Exponent, sequence ?? factor.Sequence, editable ?? factor.Editable)
 {
 }