Skip to content

Commit

Permalink
Outsourced Miscellaneous Functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikNordmeyer committed Sep 13, 2024
1 parent f84e102 commit 34f8414
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
10 changes: 10 additions & 0 deletions src/main/clojure/conexp/fca/contexts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions src/main/clojure/conexp/fca/matrices.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
)
17 changes: 0 additions & 17 deletions src/main/clojure/conexp/fca/matrix_factorizations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34f8414

Please sign in to comment.