Example #1
0
        public MatrisBase <object> Concatenate(MatrisBase <object> A,
                                               MatrisBase <object> B,
                                               int axis = 0)
        {
            if (axis == 0)
            {
                if (A.Col != B.Col)
                {
                    throw new Exception(CompilerMessage.MAT_CONCAT_DIM_ERROR("Satır"));
                }

                List <List <object> > newvals = new List <List <object> >();

                for (int r1 = 0; r1 < A.Row; r1++)
                {
                    newvals.Add(A.RowList(r1, 0));
                }
                for (int r2 = 0; r2 < B.Row; r2++)
                {
                    newvals.Add(B.RowList(r2, 0));
                }

                return(A is Dataframe df
                    ? new Dataframe(newvals,
                                    df.Delimiter,
                                    df.NewLine,
                                    null,
                                    null,
                                    df.GetRowSettings().Copy(),
                                    df.GetColSettings().Copy())
                    : new MatrisBase <object>(newvals));
            }
            else if (axis == 1)
            {
                if (A.Row != B.Row)
                {
                    throw new Exception(CompilerMessage.MAT_CONCAT_DIM_ERROR("Sütun"));
                }

                List <List <object> > newvals = new List <List <object> >();

                for (int r = 0; r < A.Row; r++)
                {
                    newvals.Add(A.RowList(r, 0));
                    newvals[r].AddRange(B.RowList(r, 0));
                }

                return(A is Dataframe df
                    ? new Dataframe(newvals,
                                    df.Delimiter,
                                    df.NewLine,
                                    null,
                                    null,
                                    df.GetRowSettings().Copy(),
                                    df.GetColSettings().Copy())
                    : new MatrisBase <object>(newvals));
            }
            else
            {
                throw new Exception(CompilerMessage.MAT_CONCAT_AXIS_ERROR);
            }
        }