Exemple #1
0
        private static String buildLCS(ulong[,,,] b, char[] X, ulong[] ind)
        {
            for (ulong i = 0; i < RANK; i++)
            {
                if (ind[i] == 0)
                {
                    return("");
                }
            }

            ulong L = b[ind[0], ind[1], ind[2], ind[3]];

            if (L == RANK)
            {
                for (ulong i = 0; i < RANK; i++)
                {
                    ind[i]--;
                }
                ulong idx = ind[0];
                return(buildLCS(b, X, ind) + X[idx]);
            }
            if (L >= 0 && L < RANK)
            {
                ind[L]--;
                return(buildLCS(b, X, ind));
            }
            throw new Exception();
        }
Exemple #2
0
        private static void findLCS(ulong[,,,] c, ulong[,,,] b, char[][] seq, ulong[] len)
        {
            ulong[] ind = new ulong[RANK];
            for (ind[0] = 1; ind[0] < len[0]; ind[0]++)
            {
                for (ind[1] = 1; ind[1] < len[1]; ind[1]++)
                {
                    for (ind[2] = 1; ind[2] < len[2]; ind[2]++)
                    {
                        for (ind[3] = 1; ind[3] < len[3]; ind[3]++)
                        {
                            bool eqFlag = true;
                            for (ulong i = 1; i < RANK; i++)
                            {
                                if (seq[i][ind[i] - 1] != seq[i - 1][ind[i - 1] - 1])
                                {
                                    eqFlag = false;
                                    break;
                                }
                            }

                            if (eqFlag)
                            {
                                c[ind[0], ind[1], ind[2], ind[3]] =
                                    c[ind[0] - 1, ind[1] - 1, ind[2] - 1, ind[3] - 1] + 1;
                                b[ind[0], ind[1], ind[2], ind[3]] = RANK;
                                continue;
                            }

                            ulong R = 0;
                            ulong M = 0;
                            for (ulong i = 0; i < RANK; i++)
                            {
                                ind[i]--;
                                if (c[ind[0], ind[1], ind[2], ind[3]] + 1 > M)
                                {
                                    R = i + 1;
                                    M = c[ind[0], ind[1], ind[2], ind[3]] + 1;
                                }
                                ind[i]++;
                            }
                            if (R == 0 || M == 0)
                            {
                                throw new Exception();
                            }

                            c[ind[0], ind[1], ind[2], ind[3]] = checked (M - 1);
                            b[ind[0], ind[1], ind[2], ind[3]] = checked (R - 1);
                        }
                    }
                }
            }
        }
Exemple #3
0
 public static extern af_err af_get_data_ptr([Out] ulong[,,,] data, IntPtr array_arr);
 public static SuperArray Create(ulong[,,,] data) => Data.CreateArray(data);
Exemple #5
0
 public static extern af_err af_create_array(out IntPtr array_arr, [In] ulong[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
Exemple #6
0
 public static extern af_err af_write_array(IntPtr array_arr, [In] ulong[,,,] data, UIntPtr size_bytes, af_source src);
Exemple #7
0
 public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ulong[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
 public static extern af_err af_get_scalar([Out] ulong[,,,] output_value, IntPtr array_arr);
Exemple #9
0
 public static extern af_err af_free_host([Out] ulong[,,,] ptr);
Exemple #10
0
 public static extern af_err af_free_pinned([Out] ulong[,,,] ptr);
Exemple #11
0
 public static extern af_err af_free_device([Out] ulong[,,,] ptr);