Element-wise Operations on CL Sequences

25 views
Skip to first unread message

Steven Núñez

unread,
Dec 27, 2014, 6:01:42 PM12/27/14
to lisp...@googlegroups.com

Seasons Greetings All,

 

I’ve had some time off over the holidays to work on a lisp project: element-wise operations on CL (common lisp) sequences. The goal is to create a package, call it cl-elt-math, within which I can get xlisp-stat style element-wise operations on sequences, including operator overloading (shadowing the CL operators).

 

I did spend some time searching for a such a package, but wasn’t able to find any that exactly meet the requirement. There is vec-math, which looks like it might work if the operators were shadowed. I also ran across cl-ana, which I didn’t know about before, a “Free (GPL) Common Lisp data analysis library with emphasis on modularity and conceptual clarity.” It seems to work, and is actively maintained, but unfortunately is infected with GPL, and since I hope to use cl-etl-math at work, rules it out.

 

The lisp-stat-math package seems to be just what I want judging from the package file:

 

(defpackage :lisp-stat-math

   (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan …   ftruncate fround signum cis)

   (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos …)

   (:documentation "Vectorization of numerical functions"))

 

Looking at the code in lsmacros, lsmath, and compound.lisp, it appears that element-wise operations are tangled up with compound-data objects and xlisp-stat style sequences, and implemented via the make-rv-function macro with support from recursive-map-elements, also part of the compound-data functions.

 

I’ve spent some hours going through this code and reading all the comments  and documentation about the design of element-wise operations in cl-stat (OK, that last part took 30 seconds J ), but am only a little closer to understanding how it works or figuring out a way to extract it for my simpler package.

 

Does anyone:

-          Know of any packages for element-wise operations on CL sequences?

-          Understand enough of the cl-stats implementation of element-wise operations to explain it?

-          Think that the cl-stat implementation can be de-tangled from the xlisp-stat object system and compound data code and made standalone?

-          Have any other ideas for a simple package for element-wise operations shadowing the CL operators?

 

Happy holidays,

-          SteveN

 

Reply all
Reply to author
Forward
0 new messages