From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: why are there [v e c t o r s] in Lisp? Date: Sat, 17 Oct 2015 18:15:47 +0200 Organization: Informatimago Message-ID: <87si59bhe4.fsf@kuiper.lan.informatimago.com> References: <87oafzpqfj.fsf@debian.uxu> <87lhb2cjy5.fsf@kuiper.lan.informatimago.com> <876126w0t8.fsf@debian.uxu> <871tctcyj3.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1445098825 32707 80.91.229.3 (17 Oct 2015 16:20:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2015 16:20:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 17 18:20:22 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZnUDT-0006w3-QE for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Oct 2015 18:20:19 +0200 Original-Received: from localhost ([::1]:59007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUDT-0004JK-3s for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Oct 2015 12:20:19 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-X-Trace: individual.net Bg5pnD6TLx0ZIQOifsKfHw5TlwAzpWAOL5lbNPWw10HIzY2vvt Cancel-Lock: sha1:YTBhMWU0NWJiYjgwOWMzMzE5YzdjZjE2NGUzZmY1YmM4ZWE2ZmQ5NA== sha1:+Se3emG5z0rdGCrObfUOORwoWSE= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:215433 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107717 Archived-At: Emanuel Berg writes: > "Pascal J. Bourguignon" > writes: > >> Obviously not. >> >> And linear algebra deals with matrices and tensors >> etc, which are arrays! > > They are not called arrays but matrices so there is no > confusing the data structure array with the linear > algebra concept matrix. Nobody but you is confusing arrays with matrices, since they're not the same thing. vectors are arrays. matrices are arrays. tensors are arrays. But you don't have arrays when you only have vectors (like in C). Notice how in CL, there's a distinction between a 3-vector and a 1,3-matrix, or a 1,1,3-array: cl-user> (make-array '(3)) #(0 0 0) cl-user> (make-array '(1 3)) #2A((0 0 0)) cl-user> (make-array '(1 1 3)) #3A(((0 0 0))) Or similary, there's a distinction between a 3,4-matrix and a 1,3,4-array: cl-user> (make-array '(3 4)) #2A((0 0 0 0) (0 0 0 0) (0 0 0 0)) cl-user> (make-array '(1 3 4)) #3A(((0 0 0 0) (0 0 0 0) (0 0 0 0))) cl-user> It's a trivial notion of subclass/superclass, if you had any object oriented knowledge. That said, while CL distinguishes a vector subclass of arrays, it doesn't name a matrix subclass. In emacs lisp, since we don't have arrays, only vectors, we have to use tricks like in C to implement matrices or tensors: (type-of (make-array '(2 3))) --> vector Happily, emacs lisp helps a little, creating a vector of vector: (make-array '(2 3)) --> [[nil nil nil] [nil nil nil]] (aref (make-array '(2 3)) 0) --> [nil nil nil] -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk