Exemplo n.º 1
0
        IObjectOperation IBinaryAcceptor.Accept(object typeA, object typeB)
        {
            IObjectOperation oo = ObjectFormulaTree.GetOperation(acceptors, typeA, typeB);

            if (oo != null)
            {
                return(oo);
            }
            Double a = 0;

            object[]          t   = new object[] { typeA, typeB };
            ArrayReturnType[] ats = new ArrayReturnType[2];
            for (int i = 0; i < t.Length; i++)
            {
                object ty = t[i];
                if (!(ty is ArrayReturnType))
                {
                    return(null);
                }
                ArrayReturnType at = ty as ArrayReturnType;
                if (at.IsObjectType)
                {
                    return(null);
                }
                if (!at.ElementType.Equals(a))
                {
                    return(null);
                }
                ats[i] = at;
                if (at.Dimension.Length != 2)
                {
                    if (i == 1)
                    {
                        goto MatVec;
                    }
                }
            }
            if (ats[0].Dimension[1] != ats[1].Dimension[0])
            {
                return(null);
            }
            int[]           n    = new int[] { ats[0].Dimension[0], ats[1].Dimension[1] };
            ArrayReturnType type = new ArrayReturnType(a, n, false);

            return(new RealMatrixMultiplication(type));

MatVec:
            if (ats[1].Dimension.Length != 1)
            {
                return(null);
            }
            if (ats[0].Dimension.Length != 2)
            {
                return(null);
            }
            if (ats[0].Dimension[1] != ats[1].Dimension[0])
            {
                return(null);
            }
            return(new RealVectorMatrixMultiplication(ats[0].Dimension[0]));
        }