public Matrix(ISemiring <T> semiring, uint height, uint width) { this.Semiring = semiring; this.Height = height; this.Width = width; this.Elements = new T[this.Height, this.Width]; }
public LiftedNestedReducer(INestedReducer <γ, T> underlying, HPredicate <Cp, T> hPredicate, List <List <Tuple <int, int> > > multMap) { _underlying = underlying; _semiring = new LiftedSemiring <γ, Cp, T>(underlying.Semiring, hPredicate, multMap); _hPredicate = hPredicate; }
public static Matrix <T> Fill(ISemiring <T> semiring, uint height, uint width, T value) { Matrix <T> matrix = new Matrix <T>(semiring, height, width); for (uint y = 0; y < matrix.Height; y++) { for (uint x = 0; x < matrix.Width; x++) { matrix.Elements[y, x] = value; } } return(matrix); }
public Matrix(ISemiring <T> semiring, T[,] elements) { this.Semiring = semiring; this.Height = (uint)elements.GetLength(0); this.Width = (uint)elements.GetLength(1); this.Elements = new T[this.Height, this.Width]; for (uint y = 0; y < this.Height; y++) { for (uint x = 0; x < this.Width; x++) { this.Elements[y, x] = elements[y, x]; } } }
public LiftedSemiring(ISemiring <γ> semiring, HPredicate <Cp, T> p, List <List <Tuple <int, int> > > multMap) { // Sanity check to make sure there's an entry in the multiplication map for // each element of the predicate's state set if (multMap.Count != p.Symbols().Count) { throw new System.Exception(string.Format("Assert failed, multMap.Count = {0} p.Symbols().Count = {1}", multMap.Count, p.Symbols().Count)); } Debug.Assert(multMap.Count == p.Symbols().Count); _semiring = semiring; _p = p; _multMap = multMap; }
public Matrix <U> Map <U>(ISemiring <U> semiring, Func <uint, uint, T, U> f, Matrix <U> result = null) { if (result != null) { Debug.Assert(result.Width == this.Width); Debug.Assert(result.Height == this.Height); } result = result ?? new Matrix <U>(semiring, this.Height, this.Width); result.Semiring = semiring; for (uint y = 0; y < this.Height; y++) { for (uint x = 0; x < this.Width; x++) { result.Elements[y, x] = f(y, x, this.Elements[y, x]); } } return(result); }
public ConveyorNR() { _semiring = new ConveyorSR(); }
public Opt(ISemiring <U> semiring, Func <T, U> preparer) { _preparer = preparer; _semiring = semiring; }
public static Matrix <T> Zero(ISemiring <T> ring, uint height, uint width) { return(Matrix <T> .Fill(ring, height, width, ring.Zero)); }
public static Matrix <T> FromArray(ISemiring <T> semiring, T[,] elements) { return(new Matrix <T>(semiring, elements)); }