示例#1
0
 public idxlooper(idx <T> m, int ld)
 {
     if (m.order() == 0)
     {
         Global.eblerror("cannot loop on idx with order 0. idx is: " + m);
     }
     i    = 0;
     dimd = m.spec.dim[ld];
     modd = m.spec.mod[ld];
     m.spec.select_into(ref spec, ld, i);
     this.srgptr = m.srgptr.Addreference();
     item        = new eptr <T>(srgptr, spec.getoffset());
 }
示例#2
0
        public static void idx_m2dotm2(idx <T> i1, idx <T> i2, idx <T> o)
        {
            eptr <T> c1, c2, c1_0, ker;
            intg     c1_m1 = i1.mod(1), c2_m0 = i2.mod(0);
            intg     j, jmax = i2.dim(0);
            intg     c1_m0 = i1.mod(0), d1_m0 = o.mod(0);
            eptr <T> d1;
            T        f;
            intg     i, imax = o.dim(0);
            intg     k, kmax = o.dim(1);

            c1 = new eptr <T>(i1.srgptr);
            c2 = new eptr <T>(i2.srgptr);
            // loop on o.dim(1)
            for (k = 0; k < kmax; ++k)
            {
                c1_0 = i1.idx_ptr();
                d1   = o.idx_ptr(); d1.index += k;
                ker  = i2.idx_ptr(); ker.index += k;
                // loop on o.dim(0)
                for (i = 0; i < imax; i++)
                {
                    f        = default(T);
                    c1.index = c1_0.index;
                    c2.index = ker.index;
                    // loop on
                    if (c1_m1 == 1 && c2_m0 == 1)
                    {
                        for (j = 0; j < jmax; j++)
                        {
                            f = Add <T>(f, Dot(c1.item, c2.item));
                            c1++; c2++;
                        }
                    }
                    else
                    {
                        for (j = 0; j < jmax; j++)
                        {
                            f         = Add <T>(f, Dot(c1.item, c2.item));// (*c1) * (*c2);
                            c1.index += c1_m1;
                            c2.index += c2_m0;
                        }
                    }
                    d1.item     = f;
                    d1.index   += d1_m0;
                    c1_0.index += c1_m0;
                }
            }
        }
示例#3
0
        public eptr <T> init(idx <T> m)
        {
            spec = m.spec;
            i    = 0;
            j    = spec.ndim;
            data = new eptr <T>(m.srgptr, spec.getoffset());

            n = spec.nelements();
            if (spec.contiguousp())
            {
                d[0] = -1;
            }
            else
            {
                for (i = 0; i < spec.ndim; i++)
                {
                    d[i] = 0;
                }
            }
            return(data);
        }