On Wed, 4 Oct 2017, oleg_komashko(a)ukr.net wrote:
Dear All,
To reproduce
x = {1,1}'
catch eval numhess(x,x'*x)
catch eval fdjac(x,x'*x)
catch eval fdjac(x,(x'*x))
function matrix i(matrix x)
return x
end function
eval numhess(x,i(x'*x))
eval fdjac(x,i(x'*x))
Why it may look trivial, I spent
some time to guess to use
identity function
I can imagine 2 possibilities:
1) to include native identity
function in hansl
2)fdjac and numhess should do
something similar inside
Ok, first things first: DON'T EVER use the Matlab-style syntax "x'*x";
it
works, but it's inefficient, both in terms of memory usage and CPU time.
Use "x'x" instead. Believe me, it does make a difference. And if you
don't
believe me, try this:
<hansl>
set verbose off
X = mnormal(2000,100)
XX = zeros(100,100)
set stopwatch
loop 100 -q
XX = X'*X
endloop
t0 = $stopwatch
loop 100 -q
XX = X'X
endloop
t1 = $stopwatch
print t0 t1
</hansl>
Having said this, fdjac and numhess are supposed to work on _functions_,
not _arbitrary expressions_. Of course Allin has the final word here, but
I imagine that allowing for arbitrary genr expressions as the second
argument would complicate the parsing quite a bit, and I don't really see
the scope for it. But I may be wrong, of course.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------