Opere consultas LINQ no espaço 'vertical' em vez de 'horizontal'
Não consigo descobrir como fazer isso, se possível.
Um exemplo:
int[][] myArrays = {
new int[] {1, 2, 3},
new int[] {4, 5, 3},
new int[] {1, 2, 3}
};
int[] avgArray = myArrays.//Some LINQ statement to average every Nth element in the second dimension (essentially "flatten" the array)
//avgArray == {2, 3, 3}
Para fazer isso até agora, só consigo pensar em:
int ndDimLen = myArrays.GetLength(1);
int[] avgArray = new int[ndDimLen];
myArrays.Select(
arr => arr.Select( (n, i) => avgArray[i] += n )
);
avgArray = avgArray.Select( n => n / ndDimLen ).ToArray();
Mas isso derrota o objetivo e não é uma idéia particularmente boa em matrizes irregulares ...
Além disso, eu definitivamente gostaria de evitar a transposição, pois é uma operação bastante lenta ao operar em matrizes grandes!
Obrigado pelo seu tempo!