Esempio n. 1
0
        public static TVal[] GetColFromLabel <TRow, TVal>(this LabelledMatrix <TRow, string, TVal> matrix, string label)
        {
            int labelIndex;

            if (!HasCol(matrix, label, out labelIndex))
            {
                throw new Exception(string.Format("Missing Label : {0}", label));
            }

            return(matrix.Values.Column(labelIndex));
        }
Esempio n. 2
0
        public static bool HasCol <TRow, TVal>(LabelledMatrix <TRow, string, TVal> matrix, string label, out int colIndex)
        {
            var labelIndexes = matrix.ColLabels
                               .Select((l, i) => new { Label = l, Index = i })
                               .Where(data => data.Label.Equals(label, StringComparison.InvariantCultureIgnoreCase))
                               .Select(data => data.Index)
                               .ToArray();

            if (!labelIndexes.Any())
            {
                colIndex = -1;
                return(false);
            }

            if (labelIndexes.Count() != 1)
            {
                throw new Exception(string.Format("Multiple {0} label !", label));
            }

            colIndex = labelIndexes.First();
            return(true);
        }
Esempio n. 3
0
 public static TValOut[] GetColFromLabel <TRow, TVal, TValOut>(this LabelledMatrix <TRow, string, TVal> matrix, string label, Func <TVal, TValOut> func)
 {
     return(matrix.GetColFromLabel(label).Map(func));
 }
Esempio n. 4
0
        public static bool HasCol <TRow, TVal>(this LabelledMatrix <TRow, string, TVal> matrix, string label)
        {
            int index;

            return(HasCol(matrix, label, out index));
        }