From: Akshay S. <ak...@us...> - 2013-02-25 18:00:07
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "matlisp". The branch, tensor has been updated via 36eb4f85eaf7042a8f2bcf7a1af1f48dddd7bb45 (commit) from 6d64374a148b18ceea55608f39b0bc0d5f8cca75 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 36eb4f85eaf7042a8f2bcf7a1af1f48dddd7bb45 Author: Akshay Srinivasan <aks...@gm...> Date: Mon Feb 25 09:54:59 2013 -0800 Added seq.lisp to the asdf load file. diff --git a/matlisp.asd b/matlisp.asd index e83b2ee..09ec278 100644 --- a/matlisp.asd +++ b/matlisp.asd @@ -157,11 +157,13 @@ :pathname "lapack" :depends-on ("matlisp-base" "matlisp-classes" "matlisp-level-1" "matlisp-level-2" "matlisp-level-3") :components ((:file "getrf"))) - #+nil (:module "matlisp-sugar" :pathname "sugar" :depends-on ("matlisp-base" "matlisp-classes" "matlisp-level-1" "matlisp-level-2" "matlisp-level-3") - :components ((:file "mplusminus") + :components ((:file "seq") + #+nil + (:file "mplusminus") + #+nil (:file "mtimesdivide"))) #+nil (:module "matlisp-reader" diff --git a/src/sugar/seq.lisp b/src/sugar/seq.lisp index 9da94ca..9c96efa 100644 --- a/src/sugar/seq.lisp +++ b/src/sugar/seq.lisp @@ -3,14 +3,14 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 2000 The Regents of the University of California. -;;; All rights reserved. -;;; +;;; All rights reserved. +;;; ;;; Permission is hereby granted, without written agreement and without ;;; license or royalty fees, to use, copy, modify, and distribute this ;;; software and its documentation for any purpose, provided that the ;;; above copyright notice and the following two paragraphs appear in all ;;; copies of this software. -;;; +;;; ;;; IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY ;;; FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ;;; ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF @@ -38,60 +38,19 @@ :do (setf (aref sto-r i) ori)) ret)))) -(defun linspace (start end &optional (num-points (1+ (abs (- start end))))) +(defun alinspace (start end &optional (num-points (1+ (abs (- start end))))) (let ((h (/ (- end start) (1- num-points)))) (arange start (+ h end) (abs h)))) -#+nil (export '(seq)) - -(if (not (fboundp '%push-on-end%)) -(defmacro %push-on-end% (value location) - `(setf ,location (nconc ,location (list ,value))))) - - -(defun seq (start step &optional end) - " - Syntax - ====== - (SEQ start [step] end) - - Purpose - ======= - Creates a list containing the sequence - - START, START+STEP, ..., START+(N-1)*STEP - - where | END-START | - N = | --------- | + 1 - | STEP | - -- -- - - The representations of START,STEP,END are - assumed to be exact (i.e. the arguments - are rationalized. - - The type of the elements in the - sequence are of the same type as STEP. - - The optional argument STEP defaults to 1. -" - (when (not end) - (setq end step) - (setq step 1)) - - (let ((start (rationalize start)) - (type (if (typep step 'integer) - 'integer - 'rational)) - (step (rationalize step)) - (end (rationalize end)) - (seq nil)) +(defun range (start end &optional (h 1)) + (declare (type real start end h)) + (let ((quo (ceiling (if (> start end) (- start end) (- end start)) h))) + (if (= quo 0) nil + (let ((h (if (> start end) (- h) h))) + (loop :for i :from 0 :below quo + :for ori := start :then (+ ori h) + :collect ori))))) - (when (zerop step) - (error "STEP equal to 0")) - (do ((x start (+ x step))) - ((if (> step 0) - (> x end) - (< x end)) - (nreverse seq)) - (push (coerce x type) seq)))) +(defun linspace (start end &optional (num-points (1+ (abs (- start end))))) + (let ((h (/ (- end start) (1- num-points)))) + (range start (+ h end) (abs h)))) ----------------------------------------------------------------------- Summary of changes: matlisp.asd | 6 +++- src/sugar/seq.lisp | 71 +++++++++++----------------------------------------- 2 files changed, 19 insertions(+), 58 deletions(-) hooks/post-receive -- matlisp |