getvariable() public method

public getvariable ( ) : VariableElement,
return VariableElement,
Ejemplo n.º 1
0
    //---------------< test stub >--------------------------------------------

    
    static void Main()
    {
         MatrixTranspose tran = new  MatrixTranspose();
         VariableElement variable = new VariableElement();
         variable.setText("a");
            tran.setvariable(variable);
            VariableElement tr;
            tr = tran.getvariable();
        
    }  
Ejemplo n.º 2
0
        public override void VisitMatrixTransposeElement(MatrixTranspose element)
        {
            if (element.getvariable() != null)
            {
                VisitElement(element.getvariable());
                Object obj_rhs = getTopOfStack_Matrix();
                //Object result = new Object();
                MatrixVariableDeclaration mat = (MatrixVariableDeclaration)(obj_rhs);
                MatrixVariableDeclaration transpose = new MatrixVariableDeclaration();
                transpose.setType(mat.getType());
                int rhs_type = GetTypeOfElement((Element)obj_rhs);
                if (rhs_type == 3)
                {
                    if (mat.getType() == "int")
                    {
                        int[,] mat_elem = mat.getintValue();

                        int row = int.Parse(((IntegerElement)(mat.getRow())).getText());
                        int col = int.Parse(((IntegerElement)(mat.getColumn())).getText());
                        int[,] trans_elem = new int[col, row];
                        transpose.setRow(mat.getColumn());
                        transpose.setColumn(mat.getRow());
                        for (int i = 0; i < row; i++)
                        {
                            for (int j = 0; j < col; j++)
                                trans_elem[j, i] = mat_elem[i, j];
                        }
                        Console.Write("\n");
                        transpose.setIntMatrix(trans_elem);
                        int[,] trans = transpose.getintValue();
                        int trans_row = int.Parse(((IntegerElement)(transpose.getRow())).getText());
                        int trans_col = int.Parse(((IntegerElement)(transpose.getColumn())).getText());
                        Console.Write("Transpose of the given matrix is : \n\n");
                        //result("Transpose of the matrix\n");

                        for (int i = 0; i < trans_row; i++)
                        {
                            for (int j = 0; j < trans_col; j++)
                            {
                                Console.Write("\t" + trans[i, j]);
                                //      result("\t" + trans[i, j].ToString());
                            }
                            Console.Write("\n");
                            //result("\n");

                        }
                    }
                    else if (mat.getType() == "double")
                    {
                        double[,] mat_elem = mat.getdoubleValue();

                        int row = int.Parse(((IntegerElement)(mat.getRow())).getText());
                        int col = int.Parse(((IntegerElement)(mat.getColumn())).getText());
                        double[,] trans_elem = new double[col, row];
                        transpose.setRow(mat.getColumn());
                        transpose.setColumn(mat.getRow());
                        for (int i = 0; i < row; i++)
                        {
                            for (int j = 0; j < col; j++)
                                trans_elem[j, i] = mat_elem[i, j];
                        }
                        Console.Write("\n");
                        //result("\n");

                        transpose.setDoubleMatrix(trans_elem);
                        double[,] trans = transpose.getdoubleValue();
                        int trans_row = int.Parse(((IntegerElement)(transpose.getRow())).getText());
                        int trans_col = int.Parse(((IntegerElement)(transpose.getColumn())).getText());
                        //result( "Transpose of the given matrix\n");
                        Console.Write("Transpose of the given matrix is : \n\n");
                        for (int i = 0; i < trans_row; i++)
                        {
                            for (int j = 0; j < trans_col; j++)
                            {
                                Console.Write("\t" + trans[i, j]);
                                //      result( "\t" + trans[i, j].ToString());

                            }
                            Console.Write("\n");
                            //result("\n");
                        }
                    }
                    Object result = (Object)(transpose);
                    mat_stack.Push(result);

                }
            }
            else
            {
                Console.Write("Matrix needs to be decalred first.. try again.. ");
                sendres(112, "Matrix needs to be declared first.. try again..\n");
            }
        }