     public func asMatrix(from: [X.Generator], to: [Y.Generator]) -> DMatrix<CoeffRing> {
         let comps = from.enumerated().flatMap { (j, a) -> [MatrixComponent<CoeffRing>] in
             let w = self.applied(to: .wrap(a))
-            return w.factorize(by: to).enumerated().compactMap { (i, a) in
-                a != .zero ? (i, j, a) : nil
-            }
+            return w.factorize(by: to).map{ (i, _, a) in (i, j, a) }
         }
         return DMatrix(size: (to.count, from.count), components: comps, zerosExcluded: true)
     }

        return elements.keys.sorted().toArray()
    }
    
    public var components: [R] {
        return elements.keys.sorted().map{ self[$0] }
    }
    
    public func factorize(by list: [A]) -> [R] {
        return list.map{ self[$0] }
    }
    
    public var isSingle: Bool {

    var elements: [Generator : CoeffRing] { get }
    static func wrap(_ a: Generator) -> Self
    static func combine<n>(basis: [Generator], vector: ColVector<n, CoeffRing>) -> Self
    func factorize(by: [Generator]) -> DVector<CoeffRing>
}

public struct FreeModule<A: FreeModuleGenerator, R: Ring>: FreeModuleType {
