Using math.js with clojurescript unsuccessfully. Please comment how to access the function of math.js with clojurescript correctly.
(ns numerical-methods.test
(:require ["mathjs" :as math]))
;; Function to create and print a vector
(defn a-vector []
(let [v [1.0 2.0 3.0]]
(println "Vector:" v)))
;; Function to compute and print the inner product of two vectors
(defn inner-product-demo []
(println "Dot product of two vectors")
(let [v1 [1.0 2.0]
v2 [3.0 4.0]
product (math/dot v1 v2)] ;; Error : hadow.js.shim.module$mathjs.dot is not a function.
(println "Inner Product:" product)))
;; Function to invert a matrix and print it
(defn invert-matrix []
(println "Invert a matrix")
(let [A [[1 2 3]
[6 5 4]
[8 7 9]]
Ainv (math/inv A)] ;; Error : shadow.js.shim.module$mathjs.inv is not a function.
(println "Inverse Matrix:")
(println Ainv)))
;; Main function to run demos
(defn -main []
(println "Chapter 1 demos")
(a-vector)
(inner-product-demo)
(invert-matrix))
;; Call the main function
(-main)
Error Message when execute in REPL.
; Execution error (TypeError) at (<cljs repl>:1).
; shadow.js.shim.module$mathjs.dot is not a function. (In 'shadow.js.shim.module$mathjs.dot(v1,v2)', 'shadow.js.shim.module$mathjs.dot' is undefined)
; Execution error (TypeError) at (<cljs repl>:1).
; shadow.js.shim.module$mathjs.inv is not a function. (In 'shadow.js.shim.module$mathjs.inv(A)', 'shadow.js.shim.module$mathjs.inv' is undefined)