Exemple #1
0
        private void Initialize(int N, int Dims, List <int>[] ids, double[][] P, double[] Y)
        {
            this.N    = N;
            this.Dims = Dims;
            this.ids  = ids;
            this.P    = P;
            this.Y    = Y;

            // initialize reusable allocations
            Grad   = new double[N * Dims];
            GradT  = new double[N * Dims];
            Ydelta = new double[N * Dims];
            gains  = new double[N * Dims];
            for (int i = N * Dims - 1; i >= 0; i--)
            {
                gains[i] = 1;
            }

            //initialize repulsion methods
            ChosenRepulsionMethod = GradientConfig.RepulsionMethod;
            if (ChosenRepulsionMethod == RepulsionMethods.auto || ChosenRepulsionMethod == RepulsionMethods.barnes_hut)
            {
                HST = new HashSpatialTree(N, Dims, Y);
            }
            if (ChosenRepulsionMethod == RepulsionMethods.auto || ChosenRepulsionMethod == RepulsionMethods.fft)
            {
                InitializeFFTRepulsion(Y, GradT);
            }
        }
Exemple #2
0
 public HSTNode(HashSpatialTree tree)
 {
     this.tree     = tree;
     this.D        = tree.D;
     this.DIds     = new int[1 << D + 1];
     this.children = new HSTNode[1 << D];
     COM           = new double[D];
 }
Exemple #3
0
 public HSTNode(HashSpatialTree tree, int[] DIds, HSTNode[] children)
 {
     this.tree     = tree;
     this.D        = tree.D;
     this.DIds     = DIds;
     Count         = DIds[1 << D] - DIds[0];
     this.children = children;
     COM           = new double[D];
 }
Exemple #4
0
        private void ChooseRepulsionMethod(long[] test_repulsion)
        {
            long min_time = long.MaxValue;

            for (int i = 1; i < test_repulsion.Length; i++)
            {
                if (min_time > test_repulsion[i])
                {
                    min_time = test_repulsion[i];
                    ChosenRepulsionMethod = (RepulsionMethods)i;
                }
            }

            Console.WriteLine("Chosen repulsion method:\t{0}", ChosenRepulsionMethod);

            if (ChosenRepulsionMethod != RepulsionMethods.barnes_hut)
            {
                HST = null;
            }
            if (ChosenRepulsionMethod != RepulsionMethods.fft)
            {
                FFTR = null;
            }
        }