Joh's blog
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
Re: Joh's blog
Thank you for the introduction, Kazimir Majorinc.
It's my blog.
It's my blog.
Re: Joh's blog
Version 10.2 will add an optional Boolean flag to the 'det' and 'invert' functions. Without the flag, both functions will return 'nil' on singular matrices as already described in the manual, but with flag either the old behavior is displayed:
Or maybe TINY in the C source should be redefined or even set to 0.0 as suggested by "Numerical recipes" as an alternative to 1.0e-20.
This would give us:
What do you think?
ps: welcome to the newLISP community
Code: Select all
; in version 10.2.0
(det '((2 -1) (4 -2))) ;=> nil
(det '((2 -1) (4 -2)) true) ;=> -4e-20
(invert '((2 -1) (4 -2))) ; nil
(invert '((2 -1) (4 -2)) true) ;=> ((5e+19 -2.5e+19) (1e+20 -5e+19))
This would give us:
Code: Select all
; in version 10.2.0
> (det '((2 -1) (4 -2)) true)
-0
> (invert '((2 -1) (4 -2)) true)
((inf -inf) (inf -inf))
>
ps: welcome to the newLISP community
Re: Joh's blog
Thanks for the proposal, Lutz.
I think that the first draft is good.
Being aware of the error of numerical calculation is required.
Then, although I thought the second idea, I had no confidence.
In the first draft, the correct result and correct recognition will be obtained.
I think that the first draft is good.
Being aware of the error of numerical calculation is required.
Then, although I thought the second idea, I had no confidence.
In the first draft, the correct result and correct recognition will be obtained.
Re: Joh's blog
Thanks for your input Joh.
We will have a solution where you can optionally substitute the pivot element with a specific value. This way both solutions are possible.
Since 10.1.12 many situations throwing a "symbol reference not found" error have been eliminated, especially for 'setf'. See the following examples from your blog http://johu02.spaces.live.com/default.aspx (February 25th):
Your definition of 'nflat':
On 10.1.7 some destructive operations (i.e. 'setf') did not work on content not referenced from a symbol. This limitation has been eliminated in 10.1.12 for 10.2.0.
So the more complex definition of 'nflat' using 'quote?' is not necessary anymore.
The same is true for the 'nconc' (works like append) function on the same blog entry, which now works in the simpler definition:
We will have a solution where you can optionally substitute the pivot element with a specific value. This way both solutions are possible.
Since 10.1.12 many situations throwing a "symbol reference not found" error have been eliminated, especially for 'setf'. See the following examples from your blog http://johu02.spaces.live.com/default.aspx (February 25th):
Your definition of 'nflat':
Code: Select all
(define-macro (nflat)
(letex (_L (args 0))
(setf _L (flat $it))))
(set 'l '(a ( b c) d))
(nflat l) ;=> (a b c d)
l ;=> (a b c d)
; throws "symbol ref error" on 10.1.7 but fine on 10.1.12
(nflat (map list '(1 2 (3 4 (5 6))))) ;=> (1 2 3 4 5 6)
So the more complex definition of 'nflat' using 'quote?' is not necessary anymore.
The same is true for the 'nconc' (works like append) function on the same blog entry, which now works in the simpler definition:
Code: Select all
(define-macro (nconc)
(letex (_L (args 0)
_A (cons 'list (args)))
(setf _L (apply append _A))))
; throws "symbol ref error" on 10.1.7 but fine on 10.1.12
(nconc '(1 2 3) '(3 4 5) '(a b c)) ;=> (1 2 3 3 4 5 a b c)
Re: Joh's blog
Thanks!
Probably, I understand. I will wait for 10.2.0.
And I will try the next code.
Is it possible?
Probably, I understand. I will wait for 10.2.0.
And I will try the next code.
Code: Select all
(module "macro.lsp")
(macro (nflat L)
(setf L (flat $it)))
Re: Joh's blog
I download V10.1.12.
And I tried.
It is very useful!
And I tried.
Code: Select all
newLISP v.10.1.12 on Win32 IPv4 UTF-8, execute 'newlisp -h' for more info.
> (module "macro.lsp")
MAIN
> (macro (nflat L) (setf L (flat $it)))
(lambda-macro (L) (expand '(setf L (flat $it))))
> (nflat (map list '(1 2 (3 4 (5 6)))))
(1 2 3 4 5 6)
> (let (lst (map list '(1 2 (3 4 (5 6))))) (nflat lst) lst)
(1 2 3 4 5 6)
> (let (lst (map list '(1 2 (3 4 (5 6))))) (nflat (lst 2)) lst)
((1) (2) (3 4 5 6))