示例#1
0
文件: Program.cs 项目: dmpots/CnC.NET
 public CnCRuntime.CnCReturn Compute(int n, CnCRuntime.ITagCollection<int> fib, CnCRuntime.ITagCollection<int> fibSum)
 {
     if (n > 1)
     {
         fib.Put(n - 2);
         fib.Put(n - 1);
         fibSum.Put(n);
     }
     return CnCRuntime.CnCReturn.Ok;
 }
示例#2
0
文件: Program.cs 项目: dmpots/CnC.NET
 public CnCRuntime.CnCReturn Compute(Microsoft.FSharp.Core.Tuple<int, int, int> tag, CnCRuntime.IItemCollection<Microsoft.FSharp.Core.Tuple<int, int, int>, double> scans, CnCRuntime.IInputCollection<Microsoft.FSharp.Core.Tuple<int, int>, double> A, CnCRuntime.IInputCollection<Microsoft.FSharp.Core.Tuple<int, int>, double> B, CnCRuntime.IInputCollection<int, int> N, CnCRuntime.IOutputCollection<Microsoft.FSharp.Core.Tuple<int, int>, double> C, CnCRuntime.ITagCollection<Microsoft.FSharp.Core.Tuple<int, int, int>> computeTags)
 {
      int i = tag.Item1;
      int j = tag.Item2;
      int k = tag.Item3;
     //printfn "Compute(%d,%d,%d)" i j k
     
     double aik = A.Get(CnCRuntime.Tuple2(i,k));
     double bkj = B.Get(CnCRuntime.Tuple2(k,j));
     double cij = scans.Get(tag) + aik * bkj;
     int nMax = N.Get(Program.nTag);
     //printfn "Compute(%d,%d,%d) Gets" i j k
     
     if (k < (nMax - 1) ) {
         //printfn "Compute(%d,%d,%d) Scans Put (%d,%d,%d)" i j k i j (k+1)
         scans.Put(CnCRuntime.Tuple3(i,j,k+1), cij);
         computeTags.Put(CnCRuntime.Tuple3(i,j,k+1));
     }    
     if(k == (nMax-1)) {
         //printfn "Compute(%d,%d,%d) C Put" i j k
         C.Put(CnCRuntime.Tuple2(i, j), cij);
     }
     //printfn "Compute(%d,%d,%d) Done" i j k    
     return CnCRuntime.CnCReturn.Ok;
 }
示例#3
0
文件: Program.cs 项目: dmpots/CnC.NET
        public CnCRuntime.CnCReturn Compute(int n, CnCRuntime.IItemCollection<int, int> fibs)
        {
            int x = fibs.Get(n - 1);
            int y = fibs.Get(n - 2);
            fibs.Put(n, x + y);

            return CnCRuntime.CnCReturn.Ok;
        }
示例#4
0
文件: Program.cs 项目: dmpots/CnC.NET
        public CnCRuntime.CnCReturn Compute(Microsoft.FSharp.Core.Tuple<int, int> tag, CnCRuntime.IOutputCollection<Microsoft.FSharp.Core.Tuple<int, int, int>, double> scans, CnCRuntime.ITagCollection<Microsoft.FSharp.Core.Tuple<int, int, int>> computeTags)
        {
            int i = tag.Item1;
            int j = tag.Item2;

            Microsoft.FSharp.Core.Tuple<int, int, int> outTag = CnCRuntime.Tuple3(i, j, 0);
            scans.Put(outTag, 0.0);
            computeTags.Put(outTag);
            return CnCRuntime.CnCReturn.Ok;
        }