Exemple #1
0
 public static GreenTensor ReShape(GreenTensor gt, int nx, int ny, int nTr, int nRc)
 {
     return(new GreenTensor(nx, ny, nTr, nRc)
     {
         _components = gt._components,
     });
 }
Exemple #2
0
        public static GreenTensor CreateGiem2gTensor(INativeMemoryProvider memoryProvider, int nx, int ny, int nTr, int nRc, List <IntPtr> giem2g_ptrs)
        {
            var gt   = new GreenTensor(memoryProvider, nx, ny, nTr, nRc);
            var dict = new Dictionary <string, Component>();

            dict.Add("giem2g", new Component(gt, (Complex *)giem2g_ptrs[0]));
            gt._components = dict;
            gt._basePtrs.AddRange(giem2g_ptrs);
            return(gt);
        }
Exemple #3
0
        public static GreenTensor Merge(GreenTensor gt1, GreenTensor gt2)
        {
            if (gt1 == Empty)
            {
                return(gt2);
            }

            if (gt2 == Empty)
            {
                return(gt1);
            }

            var newGt = new GreenTensor(gt1._memoryProvider, gt1.Nx, gt1.Ny, gt1.NTr, gt1.NRc);

            newGt._components = Merge(gt1._components, gt2._components);
            newGt._basePtrs.AddRange(gt1._basePtrs);
            newGt._basePtrs.AddRange(gt2._basePtrs);

            return(newGt);
        }
Exemple #4
0
        public static GreenTensor AllocateNew(INativeMemoryProvider memoryProvider,
                                              int nx, int ny, int nTr, int nRc, long compSize, params string[] components)
        {
            var gt       = new GreenTensor(memoryProvider, nx, ny, nTr, nRc);
            var fullSize = compSize * components.Length;

            var ptr = memoryProvider.AllocateComplex(fullSize);

            UNM.ClearBuffer(ptr, fullSize);


            var dict = new Dictionary <string, Component>();

            for (int i = 0; i < components.Length; i++)
            {
                var nextPtr = ptr + i * compSize;
                dict.Add(components[i], new Component(gt, nextPtr));
            }

            gt._basePtrs.Add(new IntPtr(ptr));
            gt._components = dict;

            return(gt);
        }
Exemple #5
0
 public Component(GreenTensor gt, Complex *ptr)
 {
     Ptr = ptr;
     _gt = gt;
 }