简体   繁体   中英

How can I filter rows based on multiple criteria from an array in IlNumerics

I would like get rows based on multiple constraints. One criteria works perfect like

A[A[full, 0] % 3 == 0, full];

But when I add a second criteria I get a compiler error. What is the correct way of doing this?

Array<double> A = new double[,] {
              { 1, 9, 20 },
              { 2, 11, 21 },
              { 9, 12, 21 },
              { 9, 13, 23 },
              { 9, 14, 24 },
              { 10, 12, 21 },
              { 14, 13, 23 },
              { 16, 14, 24 },
              { 19, 12, 21 },
              { 27, 13, 23 },
              { 23, 14, 24 },
              { 6, 15, 25 }
            };

            Array<double> matching = 
                A[A[full, 0] % 3 == 0 && A[full, 1] > 10, full];

The && operator is not overloaded for Array<T> . It returns a bool in C# - not an array as you might expect. Use the corresponding function ILMath.and(A, B) instead and it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM