예제 #1
0
        public static Tuple <int, int, double> DenseMatrixAbsoluteMaximumPosition(DenseMatrix dm)
        {
            if (dm == null)
            {
                return(new Tuple <int, int, double>(0, 0, 0.0d));
            }

            List <Tuple <int, double> > rowMaxValues = new List <Tuple <int, double> >();

            var rowEnum = dm.EnumerateRowsIndexed();

            foreach (Tuple <int, Vector <double> > curRow in rowEnum)
            {
                DenseVector curDV = (DenseVector)curRow.Item2;
                rowMaxValues.Add(new Tuple <int, double>(curDV.AbsoluteMaximumIndex(), curDV.AbsoluteMaximum()));
            }

            double      maxValue    = rowMaxValues.Max(tpl => tpl.Item2);
            int         maxValueRow = rowMaxValues.FindIndex(tpl => tpl.Item2 == maxValue);
            DenseVector maxRow      = (DenseVector)dm.Row(maxValueRow);



            return(new Tuple <int, int, double>(maxValueRow, maxRow.AbsoluteMaximumIndex(), maxValue));
        }