AIMA.Probability.Util.ProbUtil.indexesOfValue C# (CSharp) Method

indexesOfValue() public static method

public static indexesOfValue ( RandomVariable X, int idx, Object>.Map x ) : int[]
X RandomVariable
idx int
x Object>.Map
return int[]
        public static int[] indexesOfValue(RandomVariable[] X, int idx,
                                           Map<RandomVariable, Object> x)
        {
            int csize = ProbUtil.expectedSizeOfCategoricalDistribution(X);

            FiniteDomain fd = (FiniteDomain) X[idx].getDomain();
            int vdoffset = fd.getOffset(x.get(X[idx]));
            int vdosize = fd.size();
            int[] indexes = new int[csize/vdosize];

            int blocksize = csize;
            for (int i = 0; i < X.length; i++)
            {
                blocksize = blocksize/X[i].getDomain().size();
                if (i == idx)
                {
                    break;
                }
            }

            for (int i = 0; i < indexes.Length; i += blocksize)
            {
                int offset = ((i/blocksize)*vdosize*blocksize)
                             + (blocksize*vdoffset);
                for (int b = 0; b < blocksize; b++)
                {
                    indexes[i + b] = offset + b;
                }
            }

            return indexes;
        }