/// <summary>
            /// Creates and initializes a new <see cref="ComputationData"/> instance
            /// </summary>
            /// <returns>The <see cref="ComputationData"/></returns>
            public static ComputationData Create()
            {
                ComputationData data = default(ComputationData);

                data.Unzig = UnzigData.Create();
                return(data);
            }
Beispiel #2
0
            /// <summary>
            /// Creates and initializes a new <see cref="ComputationData"/> instance
            /// </summary>
            /// <returns>The <see cref="ComputationData"/></returns>
            public static ComputationData Create()
            {
                ComputationData data = default;

                data.Unzig = ZigZag.CreateUnzigTable();
                return(data);
            }
Beispiel #3
0
        public static string SimpleArgument114115(int[] source, int target, CancellationToken cancellationToken, ref double Report)
        {
            if (source.Length < 2)
            {
                return("Error. Elemens count must great equal than 2.");
            }
            int sourceLength = source.Length;

            RPNOperator[]   operatorQueue   = new RPNOperator[sourceLength * 2 - 2];
            ComputationData computationData = new ComputationData();

            computationData.operatorQueue     = operatorQueue;
            computationData.opValues          = source;
            computationData.target            = target;
            computationData.cancellationToken = cancellationToken;

            computationData.forBranchCull = new HashSet <int> [sourceLength];
            for (int i = 0; i < computationData.forBranchCull.Length; i++)
            {
                computationData.forBranchCull[i] = new HashSet <int>();
            }
            //computationData.forBranchCull = new SortedSet<int>[sourceLength];
            //for(int i=0;i < computationData.forBranchCull.Length;i++)
            //{
            //    computationData.forBranchCull[i] = new SortedSet<int>();
            //}

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Restart();
            if (_ComputeCancelableWithReport(0, 0, 0, computationData, 1, 0, ref Report))
            {
                stopwatch.Stop();
                return(string.Format("{0}={1}\nwith {2} milliseconds.", ToInfix(operatorQueue, source), target, stopwatch.ElapsedMilliseconds));
            }
            else if (cancellationToken.IsCancellationRequested)
            {
                stopwatch.Stop();
                return(string.Format("compute was canceled.\nwith {0} milliseconds.", stopwatch.ElapsedMilliseconds));
            }
            else
            {
                stopwatch.Stop();
                return(string.Format("cannot find answer.\nwith {0} milliseconds.", stopwatch.ElapsedMilliseconds));
            }
        }
 /// <summary>
 /// Initializes a default-constructed <see cref="OrigJpegScanDecoder"/> instance for reading data from <see cref="OrigJpegDecoderCore"/>-s stream.
 /// </summary>
 /// <param name="p">Pointer to <see cref="OrigJpegScanDecoder"/> on the stack</param>
 /// <param name="decoder">The <see cref="OrigJpegDecoderCore"/> instance</param>
 /// <param name="remaining">The remaining bytes in the segment block.</param>
 public static void InitStreamReading(OrigJpegScanDecoder *p, OrigJpegDecoderCore decoder, int remaining)
 {
     p->data     = ComputationData.Create();
     p->pointers = new DataPointers(&p->data);
     p->InitStreamReadingImpl(decoder, remaining);
 }
 /// <summary>
 /// Initialize the <see cref="JpegBlockProcessor"/> instance on the stack.
 /// </summary>
 /// <param name="processor">The <see cref="JpegBlockProcessor"/> instance</param>
 /// <param name="componentIndex">The current component index</param>
 public static void Init(JpegBlockProcessor *processor, int componentIndex)
 {
     processor->componentIndex = componentIndex;
     processor->data           = ComputationData.Create();
     processor->pointers       = new DataPointers(&processor->data);
 }
Beispiel #6
0
 static bool _Compute(int NumOfA, int NumOfB, int depth, ComputationData computationData)
 {
     ref var operatorQueue = ref computationData.operatorQueue;