diff --git a/src/main/clojure/conexp/fca/contexts.clj b/src/main/clojure/conexp/fca/contexts.clj index 1d7c558e..a4af4aa8 100644 --- a/src/main/clojure/conexp/fca/contexts.clj +++ b/src/main/clojure/conexp/fca/contexts.clj @@ -276,6 +276,16 @@ (let [objs (aprime ctx #{m})] [objs (oprime ctx objs)])) +(defn object-concepts [ctx] + "Returns a set of all object-concepts of the specified context." + (set (for [obj (objects ctx)] (object-concept ctx obj))) +) + +(defn attribute-concepts [ctx] + "Returns a set of all attribute-concepts of the specified context." + (set (for [attr (attributes ctx)] (attribute-concept ctx attr))) +) + (defn clarify-objects "Clarifies objects in context ctx." [ctx] diff --git a/src/main/clojure/conexp/fca/matrices.clj b/src/main/clojure/conexp/fca/matrices.clj index 455e0118..abeeee9d 100644 --- a/src/main/clojure/conexp/fca/matrices.clj +++ b/src/main/clojure/conexp/fca/matrices.clj @@ -92,3 +92,9 @@ (into [] (for [c (range (col-number M1))] (* ((M1 r) c) ((M2 r) c)))))) ) + +(defn outer-prod [v1 v2] + "Computes the outer product of two vectors." + (into [] (for [x v1] + (into [] (for [y v2] (* x y))))) +) diff --git a/src/main/clojure/conexp/fca/matrix_factorizations.clj b/src/main/clojure/conexp/fca/matrix_factorizations.clj index 7696da3f..047a1ac6 100644 --- a/src/main/clojure/conexp/fca/matrix_factorizations.clj +++ b/src/main/clojure/conexp/fca/matrix_factorizations.clj @@ -260,12 +260,6 @@ ;; https://doi.org/10.1137/1.9781611972801.15 ;; Compare Algorithm 1 -(defn outer-prod [v1 v2] - "Computes the outer product of two vectors." - (into [] (for [x v1] - (into [] (for [y v2] (* x y))))) -) - (defn- cost [patterns ctx] "computes the cost function of the given patterns. Compare Problem 1" @@ -399,17 +393,6 @@ ;; https://doi.org/10.1016/j.jcss.2009.05.002 ;; Compare Algorithm 1 -(defn object-concepts [ctx] - "Returns a set of all object-concepts of the specified context." - (set (for [obj (objects ctx)] (object-concept ctx obj))) -) - -(defn attribute-concepts [ctx] - "Returns a set of all attribute-concepts of the specified context." - (set (for [attr (attributes ctx)] (attribute-concept ctx attr))) -) - - (defn- mandatory-factors [ctx] "Computes the concepts that are both object-concepts and attribute-concepts and removes them from the incidence relation. These concepts are required