Browse Source

Wrote Logarithmic types

Samuel W. Flint 5 years ago
parent
commit
4e0d92dcb8
1 changed files with 39 additions and 2 deletions
  1. 39 2
      larcs.org

+ 39 - 2
larcs.org

@@ -453,7 +453,7 @@ Equality of constants is a bit different, and is checked as follows:
        (slot-value expression-b 'value)))
 #+END_SRC
 
-** WORKING Compound Types [3/7]
+** WORKING Compound Types [4/7]
 :PROPERTIES:
 :ID:       a0d2eb19-8a1e-4dee-9b41-c454a49cacc4
 :END:
@@ -560,7 +560,43 @@ There are two primary forms of exponential -- the natural (~exp~) and the genera
                    :value 2.71828))
 #+END_SRC
 
-*** TODO Logarithmics
+*** DONE Logarithmics
+CLOSED: [2019-01-05 Sat 15:47]
+:PROPERTIES:
+:ID:       7d4a23af-6c6b-4ae3-a8af-e477cbee9082
+:END:
+
+~<logarithmic>~ and ~<nat-logarithmic>~ are very much like the above definition of ~<expt>~ and ~<exp>~, with similar conditions for ~eqal~, the only difference is semantic, being that logarithmic expressions are evaluated differently.
+
+#+Caption: Logarithmics
+#+Name: type-logarithmics
+#+BEGIN_SRC lisp 
+  @export
+  (defclass <logarithmic> (<compound>)
+    ((base :reader base
+           :initarg :base
+           :type <expression>)
+     (log-of :reader log-of
+             :initarg :log-of
+             :type <expression>)))
+
+  @export
+  (defclass <nat-logarithmic> (<logarithmic>)
+    ((log-of :reader log-of
+             :initarg :log-of
+             :type <expression>)))
+
+  (defmethod base ((expression <nat-logarithmic>))
+    (make-instance '<constant>
+                   :name :e
+                   :value 2.7818))
+
+  (defmethod eqal ((expression-a <logarithmic>) (expression-b <logarithmic>))
+    (and (eqal (base expression-a)
+             (base expression-b))
+       (eqal (log-of expression-a)
+             (log-of expression-b))))
+#+END_SRC
 
 *** TODO Trigonometric
 
@@ -1995,6 +2031,7 @@ As all of the packages are defined centrally, this makes resolving inter-package
   <<type-multiplications>>
   <<type-division>>
   <<type-exponentials>>
+  <<type-logarithmics>>
 
   <<type-poly-term>>
 #+END_SRC