Skip to content

Commit fe6837f

Browse files
committed
import version 0.2.9, 2008-08-26
- decoupled symbol class from matrix class: - matrix.replace has new semantics, applying a function to each element. For old behavior: mtx = mtx:replace(matrix.symbol.makereplacer(...)) - replaced mtx:gsub(a,b) with mtx = mtx:replace(symbol.gsub,a,b) - replaced matrix.tosymbol(mtx) with mtx = mtx:replace(symbol) - eliminated dependency on complex: - replaced matrix.tocomplex(mtx) with mtx = mtx:replace(complex) - replaced matrix.conjugate(mtx) with mtx = mtx:replace(complex.conjugate) - mulnum and divnum no longer can take num of type string - complex table no longer returned on module load - renamed remcomplex to elementstostrings and changed it to return new matrix rather than doing in-place modification - fixed matrix.numround (numround variable mispelled). Reported by Goeff Richards.
1 parent 67f7243 commit fe6837f

14 files changed

+448
-401
lines changed

LICENSE.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
LuaMatrix License
2+
-----------
3+
4+
LuaMatrix ( http://luamatrix.luaforge.net/ ) is licensed under the
5+
same terms as Lua (MIT license) reproduced below. This means that
6+
LuaMatrix is free software and can be used for both academic and
7+
commercial purposes at absolutely no cost.
8+
9+
For details and rationale, see http://www.lua.org/license.html .
10+
11+
===============================================================================
12+
13+
Copyright (C) 2007-2010 Michael Lutz.
14+
15+
Permission is hereby granted, free of charge, to any person obtaining a copy
16+
of this software and associated documentation files (the "Software"), to deal
17+
in the Software without restriction, including without limitation the rights
18+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
copies of the Software, and to permit persons to whom the Software is
20+
furnished to do so, subject to the following conditions:
21+
22+
The above copyright notice and this permission notice shall be included in
23+
all copies or substantial portions of the Software.
24+
25+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31+
THE SOFTWARE.
32+
33+
===============================================================================
34+
35+
(end of COPYRIGHT)

README.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
== Description ==
2+
3+
LuaMatrix - Matrices and matrix operations implemented in pure Lua.
4+
5+
This supports operations on matrices and vectors whose elements are
6+
real, complex, or symbolic. Implemented entirely in Lua as tables.
7+
Includes a complex number data type too.
8+
9+
For details on use, see the comments in matrix.lua and complex.lua,
10+
as well as the test suite.
11+
12+
To install, copy matrix.lua and complex.lua into your LUA_PATH. The
13+
modules can alternately be installed via LuaRocks ("luarocks install
14+
luamatrix").
15+
16+
== Project Page ==
17+
18+
http://lua-users.org/wiki/LuaMatrix
19+
20+
== License ==
21+
22+
See the LICENSE.txt file for licensing details.

complex_changelog.txt renamed to doc/complex_changelog.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
complex changelog
12

2-
complex changelog:
3+
v 0.3.1: 2007-11-12
4+
[ David Manura ]
5+
rename mulconjugate to norm2
36

47
v 0.3.0: 2007-08-26
58
- fixed print function
File renamed without changes.

matrix_changelog.txt renamed to doc/matrix_changelog.txt

+18-46
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,21 @@
1-
matrix function list:
2-
3-
matrix.add
4-
matrix.columns
5-
matrix.concath
6-
matrix.concatv
7-
matrix.conjugate
8-
matrix.copy
9-
matrix.cross
10-
matrix.det
11-
matrix.div
12-
matrix.divnum
13-
matrix.dogauss
14-
matrix.getelement
15-
matrix.gsub
16-
matrix.invert
17-
matrix.ipairs
18-
matrix.latex
19-
matrix.len
20-
matrix.mul
21-
matrix.mulnum
22-
matrix:new
23-
matrix.normf
24-
matrix.normmax
25-
matrix.pow
26-
matrix.print
27-
matrix.random
28-
matrix.remcomplex
29-
matrix.replace
30-
matrix.root
31-
matrix.rotl
32-
matrix.rotr
33-
matrix.round
34-
matrix.rows
35-
matrix.scalar
36-
matrix.setelement
37-
matrix.size
38-
matrix.solve
39-
matrix.sqrt
40-
matrix.sub
41-
matrix.subm
42-
matrix.tocomplex
43-
matrix.tostring
44-
matrix.tosymbol
45-
matrix.transpose
46-
matrix.type
1+
matrix changelog
2+
3+
v 0.2.9: 2008-08-26
4+
[ David Manura ]
5+
- decoupled symbol class from matrix class:
6+
- matrix.replace has new semantics, applying a function to each element.
7+
For old behavior: mtx = mtx:replace(matrix.symbol.makereplacer(...))
8+
- replaced mtx:gsub(a,b) with mtx = mtx:replace(symbol.gsub,a,b)
9+
- replaced matrix.tosymbol(mtx) with mtx = mtx:replace(symbol)
10+
- eliminated dependency on complex:
11+
- replaced matrix.tocomplex(mtx) with mtx = mtx:replace(complex)
12+
- replaced matrix.conjugate(mtx) with mtx = mtx:replace(complex.conjugate)
13+
- mulnum and divnum no longer can take num of type string
14+
- complex table no longer returned on module load
15+
- renamed remcomplex to elementstostrings and changed it to return new
16+
matrix rather than doing in-place modification
17+
- Fixed matrix.numround (numround variable mispelled).
18+
Reported by Goeff Richards.
4719

4820
v 0.2.8: 2007-08-26
4921
[ Michael Lutz ]

complex.lua renamed to lua/complex.lua

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- complex 0.3.0
1+
-- complex 0.3.1
22
-- Lua 5.1
33

44
-- 'complex' provides common tasks with complex numbers
@@ -15,8 +15,7 @@
1515
-- the access is faster than in a hash table
1616
-- the metatable is just a add on, when it comes to speed, one is faster using a direct function call
1717

18-
-- http://luaforge.net/projects/LuaMatrix
19-
-- http://lua-users.org/wiki/ComplexNumbers
18+
-- http://luamatrix.luaforge.net
2019

2120
-- Licensed under the same terms as Lua itself.
2221

@@ -191,9 +190,10 @@ function complex.polardeg( cx )
191190
return math.sqrt( cx[1]^2 + cx[2]^2 ), math.atan2( cx[2], cx[1] ) / math.pi * 180
192191
end
193192

194-
-- complex.mulconjugate( cx )
195-
-- multiply with conjugate, function returning a number
196-
function complex.mulconjugate( cx )
193+
-- complex.norm2( cx )
194+
-- multiply with conjugate, function returning a scalar number
195+
-- norm2(x + i*y) returns x^2 + y^2
196+
function complex.norm2( cx )
197197
return cx[1]^2 + cx[2]^2
198198
end
199199

@@ -330,6 +330,10 @@ function complex.round( cx,idp )
330330
math.floor( cx[2] * mult + 0.5 ) / mult }, complex_meta )
331331
end
332332

333+
--// variables
334+
complex.zero = complex.new(0, 0)
335+
complex.one = complex.new(1, 0)
336+
333337
--// metatable functions
334338

335339
complex_meta.__add = function( cx1,cx2 )

0 commit comments

Comments
 (0)