コード例 #1
0
        public void TestArgsort()
        {
            int[] args = ArrayUtils.Argsort(new int[] { 11, 2, 3, 7, 0 });
            Assert.IsTrue(Arrays.AreEqual(new int[] { 4, 1, 2, 3, 0 }, args));

            args = ArrayUtils.Argsort(new int[] { 11, 2, 3, 7, 0 }, -1, -1);
            Assert.IsTrue(Arrays.AreEqual(new int[] { 4, 1, 2, 3, 0 }, args));

            args = ArrayUtils.Argsort(new int[] { 11, 2, 3, 7, 0 }, 0, 3);
            Assert.IsTrue(Arrays.AreEqual(new int[] { 4, 1, 2 }, args));

            // Test double version
            int[] d_args = ArrayUtils.Argsort(new double[] { 11, 2, 3, 7, 0 }, 0, 3);
            Assert.IsTrue(Arrays.AreEqual(new int[] { 4, 1, 2 }, d_args));

            d_args = ArrayUtils.Argsort(new double[] { 11, 2, 3, 7, 0 }, -1, 3);
            Assert.IsTrue(Arrays.AreEqual(new int[] { 4, 1, 2, 3, 0 }, d_args));
        }