Beispiel #1
0
        public static void AddXYTran(AlignedArray x, AlignedArray y, int[] starts, int[] indices,
                                     float[] coefs, float[] accGrads, float[] accUpdates, float decay, float cond, int crow)
        {
            Contracts.Assert(Compat(x));
            Contracts.Assert(Compat(y));
            Contracts.Assert(0 < crow && crow <= x.Size);
            Contracts.AssertNonEmpty(starts);
            Contracts.Assert(starts.Length == crow + 1);
            Contracts.Assert(starts[0] == 0);
            Contracts.AssertNonEmpty(indices);
            Contracts.Assert(starts[crow] == indices.Length);
            Contracts.AssertNonEmpty(coefs);
            Contracts.Assert(indices.Length == coefs.Length);
            Contracts.Assert(crow * y.Size >= coefs.Length);
            Contracts.AssertNonEmpty(accGrads);
            Contracts.Assert(coefs.Length == accGrads.Length);
            Contracts.AssertNonEmpty(accUpdates);
            Contracts.Assert(coefs.Length == accUpdates.Length);

            unsafe
            {
                fixed(float *px = &x.Items[0])
                fixed(float *py     = &y.Items[0])
                fixed(int *pstarts  = &starts[0])
                fixed(int *pindices = &indices[0])
                fixed(float *pcoefs = &coefs[0])
                fixed(float *pag    = &accGrads[0])
                fixed(float *pau    = &accUpdates[0])
                Thunk.AddXYTranGradRX(Ptr(x, px), Ptr(y, py), pstarts, pindices, pcoefs, pag, pau, decay, cond, crow);
            }
        }