Esempio n. 1
0
        static public Matrix <TRowKey, TColKey, double> LinearTransformRowsView <TRowKey, TColKey>(this Matrix <TRowKey, TColKey, double> parentMatrix, Matrix <TRowKey, string, LinearTransform> linearTransformMatrix)
        {
            Helper.CheckCondition(parentMatrix.RowKeys.SequenceEqual(linearTransformMatrix.RowKeys), "Expect the parentMatrix and the linearTransformMatrix to have the same rowKeys in the same order.");

            //If the new won't change anything, just return the parent
            if (linearTransformMatrix.Values.All(linearTransform => linearTransform.IsIdentity))
            {
                return(parentMatrix);
            }

            //!!!Could check of this is a SelectRowsAndColsView of a SelectRowsAndColsView and simplify (see TransposeView for an example)

            var matrixView = new LinearTransformRowsView <TRowKey, TColKey>();

            matrixView.SetUp(parentMatrix, linearTransformMatrix);
            return(matrixView);
        }
Esempio n. 2
0
        static public Matrix <TRowKey, TColKey, double> LinearTransformRowsView <TRowKey, TColKey>(this Matrix <TRowKey, TColKey, double> parentMatrix, IList <LinearTransform> linearTransformList)
        {
            Helper.CheckCondition(linearTransformList.Count == parentMatrix.RowCount, "Expect one item in linearTransformList for each row of the parent matrix");

            //If the new won't change anything, just return the parent
            if (linearTransformList.All(linearTransform => linearTransform.IsIdentity))
            {
                return(parentMatrix);
            }

            //!!!Could check of this is a SelectRowsAndColsView of a SelectRowsAndColsView and simplify (see TransposeView for an example)

            var matrixView = new LinearTransformRowsView <TRowKey, TColKey>();

            matrixView.SetUp(parentMatrix, linearTransformList);
            return(matrixView);
        }