Jump to content

Recommended Posts

Posted (edited)

@RTFC:

Would you like to update unexpected behavior functions - _CwiseScalarOp... and _CwiseUnaryOp?

From Help:

 Apply [operator, scalar] to each cell of matrix A, storing the result in-place

Maybe it would be better to have two variant: - to store in-place and not (default)

These functions have tacit return by ref for passed matrix.

 

Example shows this tacit return by ref. Let us have two expression:

A = xC - yD

B = yC - xD

There are two version by E4A:

; long version I
; It returns valid result

;Matrix A
  $matT = _Eigen_CloneMatrix ($matC)
  _Eigen_CwiseScalarOp($matT,"*", $x)
  $matT1 = _Eigen_CloneMatrix ($matD)
 _Eigen_CwiseScalarOp($matT1,"*", $y)
  $matA = _Eigen_CwiseBinaryOp($matT,"-",$matT1)
_MatrixDisplay ( $matA, "$matA" )

  ;Matrix B
  $matT = _Eigen_CloneMatrix ($matC)
  _Eigen_CwiseScalarOp($matT,"*", $y)
  $matT1 = _Eigen_CloneMatrix ($matD)
 _Eigen_CwiseScalarOp($matT1,"*", $x)
  $matB = _Eigen_CwiseBinaryOp($matT,"-",$matT1)
_MatrixDisplay ( $matB, "$matB" )

; short version II
; Now it returns invalid result!

  $matA = _Eigen_CwiseBinaryOp(_Eigen_CwiseScalarOp($matC,"*", $x),"-",_Eigen_CwiseScalarOp($matD,"*", $y))
  $matB = _Eigen_CwiseBinaryOp(_Eigen_CwiseScalarOp($matC,"*", $y),"-",_Eigen_CwiseScalarOp($matD,"*", $x))
Edited by ValeryVal

The point of world view

Posted (edited)

Hmm, never tested that particular embedded scenario.

I'll have a look at it...

Thanks for flagging this issue.

EDIT: Okay, I've had a look. ;)

First off, these E4A functions work exactly as advertised. Your short version II returns a different result from your longer version I because you are doing something different, so technically, the returned result is not invalid, it's just different from what you apparently expected. To use the short, embedded calls version, you should have done this:

$matCC=_Eigen_Clone($matC)
$matDD=_Eigen_Clone($matD)
$matA = _Eigen_CwiseBinaryOp(_Eigen_CwiseScalarOp($matC,"*", $x),"-",_Eigen_CwiseScalarOp($matD,"*", $y))
_MatrixDisplay ( $matA, "$matA" )
$matB = _Eigen_CwiseBinaryOp(_Eigen_CwiseScalarOp($matCC,"*", $y),"-",_Eigen_CwiseScalarOp($matDD,"*", $x))
_MatrixDisplay ( $matB, "$matB" )

After the first embedded call, the contents of matC and matD have changed, so you'd get a different result in the second embedded call. I would argue this is completely expected behaviour; if you change contents in place, you cannot expect the next operation to still use the original content. :rolleyes:

Now this is not to say you don't have a valid point... :think:

I can see that inPlace vs new results matrix variants might be useful and would be in keeping with the way E4A functions are structured.This would however be script-breaking changes for all (well, most) Cwise functions, and there are an awful lot of them to fix. :wacko: But as the festive season is approaching, I'll probably find some time over the next few weeks to implement this additional functionality. After all, what are holidays for anyway? :blink::) I'll see if I can squeeze it into the next release.

Just as long as we're clear this is neither a bug nor an unexpected result, okay? ;):muttley:

 

Edit: as of E4A version 2.3, Cwise functionality has changed; the default functions now store the result in a new results matrix R, whereas a separate funvction with suffix _InPlace perfoms the original operation. This is the way ValeryVal expected these functions to work, and in retrospect I agree that it makes more sense this way.

Edited by RTFC
Posted (edited)

Hmm, never tested that particular embedded scenario.

 

BTW. This known "bug" is from time of Fortran (pass-by-reference language). Example:

http://stackoverflow.com/questions/7994360/passing-arguments-by-pass-by-reference-to-a-swap-function

So according to assertion that "we can know more than we can tell" (See http://en.wikipedia.org/wiki/Tacit_knowledge) my script induces me to remember about one real girl making that tacit returns by ref from many nested procedures (fifth or more levels). It was very severe work to fish out her hand coding.

:bye:

 

...

I can see that inPlace vs new results matrix variants might be useful and would be in keeping with the way E4A functions are structured.This would however be script-breaking changes for all (well, most) Cwise functions, and there are an awful lot of them to fix. :wacko: But as the festive season is approaching, I'll probably find some time over the next few weeks to implement this additional functionality. After all, what are holidays for anyway? :blink::) I'll see if I can squeeze it into the next release.

Just as long as we're clear this is neither a bug nor an unexpected result, okay? ;):muttley:

 

In any case I've written valid script to solve my tasks under Eigen4AutoIt v.2.2

Thank you.

;-)

Edited by ValeryVal

The point of world view

Posted

That sounds like fun. :x^_^

But the benefit of such experiences is that it rids you of one's own tacit assumptions that everyone else sees the world (or solves its problems) in the same way you do yourself. :lol: 

Posted

That sounds like fun. :x^_^

But the benefit of such experiences is that it rids you of one's own tacit assumptions that everyone else sees the world (or solves its problems) in the same way you do yourself. :lol:

 

ValeryVal:

Everyone has own unique tacit knowledge. However, not everyone has ability to tell about it.

The point of world view

  • 2 weeks later...
Posted (edited)

:sorcerer: Xmas Version 2.3 released.

Following ValeryVal's interesting suggestion, all Cwise and related functions have now been split into a regular version (storing output in new results matrix R) and an in-place version (these latter versions used to be the default, but are now accessed by adding the _InPlace suffix to the function name, as would be expected). Upon deep reflection after two weeks of fasting in a Himalayan cave, I came to the conclusion that  the proposed new arrangement is internally far more consistent and flexible than my original design, even though this implies SCIRPT-BREAKING CHANGES for all Cwise functions! :mad2: NB This includes Conditional Cwise functions.

As feared, this was rather a lot of work:

Added Functions:

E4A functions: +40

dll variants: +253! :

alias wrappers: +106

Needless to say, the package has gained some extra weight in the process, now taking almost 25 MB to install uncompressed :whistle: .

Originally I'd planned to add graphics support in this release,but that'll have to wait until I've sorted out a number of other issues, after recovering over the Xmas break from this latest effort. :sweating:  Additional info on the few other changes and fixes in this release can be found as usual in the History/ChangeLog in the Help file (online version already updated too).

So ValeryVal, I hope these additions satisfy your requirements. Anyone else who is vexed/annoyed/disgruntled/homicidal upon discovering all Cwise functions no longer work as advertised earlier, please get in touch with ValeryVal; :P I just work here. :lol:

Happy holidays!

Edited by RTFC
Posted (edited)

:sorcerer: Xmas Version 2.3 released.

So ValeryVal, I hope these additions satisfy your requirements. Anyone else who is vexed/annoyed/disgruntled/homicidal upon discovering all Cwise functions no longer work as advertised earlier, please get in touch with ValeryVal; :P I just work here. :lol:

 

Happy holidays!

 

Yes! I'm ready to foil any onrush to 2.3.

I guess you were near the entrance to Shambhala from that trans-Himalayan cave.

shambhala-kingdom.jpg

Meantime I've found the Efficient Portfolio Frontier by means E4A

and Robert C. Merton article 

http://www.people.hbs.edu/rmerton/analytical%20derivation.72.pdf

Thank you.

Happy New Year

Edited by ValeryVal

The point of world view

Posted (edited)

Ah yes, I got lost and then passed that place on my way up to the cave I'd rented, and asked if I could spend the night there, but this fat guy Lord Maitreya something or other flatly refused me entry, mumbling about impure souls and karmic burden and whatnot. Said I would have to make quite a bit more code available to the forum before he'd even discuss my ever coming back there, with my blemished record in this life and several others before that. :mad: Burned my maps too, then had his yaks chase me down the road. Well, guess who's not getting a favourable write-up from me on the holiday destination review websites... That'll teach him.

BTW, you never cease to amaze me, a typewritten paper from 1972? Where do you dig up these little gems? :) So if this financial stuff works out for you, you won't forget this humble servant who gave you access to Eigen's wonderful functions, now would you? I'm really good at keeping secrets too... :shhh:

Edited by RTFC
Posted (edited)

>a typewritten paper from 1972...this financial stuff works out for you

Hmm. Long John Silver from Treasure Island are using old and smoky map of island

treasure-Island.jpg

>I'm really good at keeping secrets too

This secret is simple.

Long John Silver tell about how he keeps his wealth,

I puts it all away, some here, some there, and none too much anywheres…”

180px-Long_John_Silver-1-.jpg

:)

BTW Have you read a story of previous Silver's life

Flint and Silver: A Prequel to Treasure Island

http://www.amazon.com/Flint-Silver-Prequel-Treasure-Island/dp/B004JZWOPG

John Silver had never killed a man. Until now, his charisma, sheer size and, when all else failed, powerful fists had been enough to dispatch his enemies. But on a smoldering deck off the coast of Madagascar, his shipmates dead or dying all around him, his cutlass has just claimed the lives of six pirates. Surrounded by their revenge-thirsty crewmates, Silver fears for his life, but then the pirate captain makes him an offer he can’t refuse.

On the other side of the world, Joseph Flint, a naval officer wronged by his superiors, plots a bloody mutiny. Strikingly handsome, brilliant but prey to sadistic tendencies, Flint is regarded as the most dangerous bandit on the high seas and fate would have it that his course intersects with Silver’s.

Together these gentlemen of fortune forge a deadly and unstoppable partnership, steering a course through treachery and betrayal while amassing vast treasure.

Edited by ValeryVal

The point of world view

  • 2 months later...
Posted (edited)

When I try to run any of the examples, the process just run and never returns, and has to be killed manually.

I'm using the latest version of autoit and the script is pointing to the directory of the DLLs.

I'm not getting any error, the process just runs until it's killed.

I don't know this is an error with the engine, the wrapper, or if I'm just plain missing something obvious.

Edited by nullschritt
Posted (edited)

Sorry nullschritt, that's not enough information for me to figure out what might be going wrong in your environment. <_<

Which example script were you running? What OS? Are you running AutoIt 3.3.12? How far does the example script get? Up to _Eigen_Startup? Up to the first dll call? Which dll call(s) fail(s)?

As several hundred other users are not experiencing such a total failure, I would hazard a guess that something in your particular set-up is not working the way it should. I haven't come across this situation, else it would be documented in the remarks section of the main script.

Edit: you may wish to check that your downloaded dlls are not corrupted:

E4A v.2.3: EigenDense.dll, 3,926,016 bytes, MD5: 0xDA2EA43A53782B56EF19AC1A4B68CBC9

E4A v.2.3: EigenDense_Debug.dll, 5,680,640 bytes, MD5: 0x817AB67DABC8D584A881F6E2235DB5B9

 

Note to all other users as well: the wrapper for _Eigen_OuterProduct() contains a bug that will be fixed in the next release (that will also incorporate the latest Eigen release), within the next few weeks, as soon as multi-processing has passed the initial testing phase. In the meantime, the function will only work if the two input vectors are parsed in the order: colvector, rowvector (it's supposed to reverse the order internally otherwise, but this currently fails, due to a brainfade when I wrote that wrapper).

Edited by RTFC
Posted (edited)

Okay I just didn't have the path right, but now I am experiencing a small hiccup. With my native matrix multiply function my matricies all multiply fine.

But when I try to replace it with your functions, it throws an error saying it's expecting 10 values when there are only 8, and it should never be expecting 10 values because all the matrices are 8x8.

Edit: I lied, one of the arrays does have 10 rows, but it's within the rules of matrix multiplication (a 10x8 matrix * a 8x8 matrix) as only the columns have to match, not rows. 

Edit Edit: Is this because the empty array I'm using as a placeholder is only 8x8? If so, is there a way to get the size of a matrix, so my code knows what size to make the empty array?

Edited by nullschritt
Posted

nullschritt,

You really should read about matrix operations. The matrix multiply op (dot in matrix parlance) goes as follows: A.B with A dimension NxK and B KxN.

So to perform the product of a 10x8 matrix with B, B must have dimension 8x10.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

@jchd: Thank you!

@nullschritt: Well, I'm glad your initial problem was resolved. As far as getting matrix properties, you may seek enlightenment in the extensive Help file (also online); :rolleyes: in section Matrix Management you'll find functions such as GetMatrixRows, GetMatrixCols, GetMatrixType, etc. If you want more information on the matrix contents, study section Reduction (specifically the MatrixSpecs functions).

And to clarify your matrix multiplication issues , you could read the Help file's section on Matrix Multiplication, or study this image:


post-81417-0-42379500-1426156011_thumb.j

Note that matrix multiplication is NOT commutative, so A.B is not the same as B.A.

Finally, I'd also like to gently remind you of the posting rules I stated in post #1 of this thread, notably, that I won't be answering any basic maths questions :naughty: ; I've listed several internet resources in the Remarks section of the main script (Eigen4AutoIt.au3) to get novice users started, but other than that, you'll have to work it out yourself. It's definitely worth it; maths looks different (and often easier) when viewed through a matrix lens.

Edited by RTFC
Posted (edited)

@jchd: Thank you!

@nullschritt: Well, I'm glad your initial problem was resolved. As far as getting matrix properties, you may seek enlightenment in the extensive Help file (also online); :rolleyes: in section Matrix Management you'll find functions such as GetMatrixRows, GetMatrixCols, GetMatrixType, etc. If you want more information on the matrix contents, study section Reduction (specifically the MatrixSpecs functions).

And to clarify your matrix multiplication issues , you could read the Help file's section on Matrix Multiplication, or study this image:

 

Note that matrix multiplication is NOT commutative, so A.B is not the same as B.A.

Finally, I'd also like to gently remind you of the posting rules I stated in post #1 of this thread, notably, that I won't be answering any basic maths questions :naughty: ; I've listed several internet resources in the Remarks section of the main script (Eigen4AutoIt.au3) to get novice users started, but other than that, you'll have to work it out yourself. It's definitely worth it; maths looks different (and often easier) when viewed through a matrix lens.

I wasn't asking a math question I KNOW how matrix multiplication works(the rules), I'm already doing it with NATIVE autoit functions. I stated that already, yet everyone seems to be under the impression I'm asking math questions, when I'm asking questions about the UDF. I was asking a question about your UDF, specifically, if my problem was that the place-holder array was too small for the output of the problem, and how to get the size to correct the problem. (: Which you did answer, thank you.

Edit: Would you maybe consider automatically putting the output of matrix math problems into an array properly sized for it, as opposed to having to manually define the size of the output matrix each time?

It would save a LOT of lines of code.

Edited by nullschritt
Posted (edited)

nullschritt,

You really should read about matrix operations. The matrix multiply op (dot in matrix parlance) goes as follows: A.B with A dimension NxK and B KxN.

So to perform the product of a 10x8 matrix with B, B must have dimension 8x10.

@jchd you should really fully read a conversation before you reply. It seems often that the MVPs on this forum skip over large parts of important conversation and make quick posts based on incomplete information, just further filling the thread with useless junk posts. Not saying you all don't know what you're talking about, but you really should pay more attention to the thread you;re posting in before posting in it, and if you dont have the time, well then, you don't have the time and there's no need for you to post other than to get your post counts up. I'm trying not to be rude, but over the past 3 days I;ve seen at least 3 MVPs post totally irrelevant replies just because they didn't fully read the posts/thread. This is the kind of posting etiquette I would expect from absolute newbies to the forum not experience "valued" members. Not only does it clutter the tread, but it then other's follow in your foot steps. Resulting in even more irrelevant information. You guys are smart, but you seem a bit slack when it comes to fully reading/retaining threads before you post.

Edit: You literally just said the exact same sentence as my question, but in a statement.

Edited by nullschritt
Posted (edited)

@nullschritt: one of the advantages of the E4A environment is that you don't have to provide an output matrix (or several results matrices, some UDFs can produce over a dozen per call) in advance; instead you just parse the matrix IDs of your inputs, and the UDF automatically creates an output of the right dimensions for you, stores the result in there, and returns its handle to you (that is, the matrix ID, i.e., its index to the global array $matrixlist). For flexibility, you can alternatively pre-create the output container(s) and parse it/them explicitly (this can be useful to re-use/conserve memory resources, for example), but normally , you never have to think about what size your output(s) should be until after you receive them.

Secondly, if your calculation comes back with an error message that there's something wrong with the dimensions of your matrices, then if your first reaction is to suspect a bug rather than a simple mistake on your part, then you could at least test this assumption thoroughly before posting. So you could examine the AutoIt wrapper for _Eigen_Multiply_AB, inspect the C++ dll source code I wrote for that function, read up on the intricacies of matrix multiplication, visit Eigen's own forum, and (most helpful would be to) write a tiny test script that reproduces the bug, so I can actually figure out what's going wrong, if something really is going wrong. I'm still weeding out bugs, typos, and oversights, so it's perfectly possible that you stumble across these, but please take the time and effort to rule out an error on your part before you post here that something unexpected occurred.

Edited by RTFC
Posted

@nullschritt: one of the advantages of the E4A environment is that you don't have to provide an output matrix (or several results matrices, some UDFs can produce over a dozen per call) in advance; instead you just parse the matrix IDs of your inputs, and the UDF automatically creates an output of the right dimensions for you, stores the result in there, and returns its handle to you (that is, the matrix ID, i.e., its index to the global array $matrixlist). For flexibility, you can alternatively pre-create the output container(s) and parse it/them explicitly (this can be useful to re-use/conserve memory resources, for example), but normally , you never have to think about what size your output(s) should be until after you receive them.

Secondly, if your calculation comes back with an error message that there's something wrong with the dimensions of your matrices, then if your first reaction is to suspect a bug rather than a simple mistake on your part, then you could at least test this assumption thoroughly before posting. So you could examine the AutoIt wrapper for _Eigen_Multiply_AB, inspect the C++ dll source code I wrote for that function, read up on the intricacies of matrix multiplication, visit Eigen's own forum, and (most helpful would be to) write a tiny test script that reproduces the bug, so I can actually figure out what's going wrong, if something really is going wrong. I'm still weeding out bugs, typos, and oversights, so it's perfectly possible that you stumble across these, but please take the time and effort to rule out an error on your part before you post here that something unexpected occurred.

I did edit the post to point out the error was on my part, I was pre-defining the emprty matrix and placing the output matrix in it, as shown in the example, I didn't realize it didn't need to be pre-defined, thanks!

Posted

That's okay, nullschritt, and you're welcome. But the E4A Help file really is your friend here; the optional outputs are mentioned on virtually every page that describes a computational function, at the bottom of the table of parsed arguments (below the function defintion box). A single results matrix is (usually) generically referred to as $matR. It would make me very happy to know that people actually consult that Help doc, as it took me considerable effort to produce it. :mellow:

Posted

nullschritt,

Thank you very much for your lecture but you seem to have forgotten what you yourself said:

 

one of the arrays does have 10 rows, but it's within the rules of matrix multiplication (a 10x8 matrix * a 8x8 matrix) as only the columns have to match, not rows

I was answering the part in bold and especially the underscored part, which is just plain wrong.

Now about my post count, don't worry any more about me answering to you.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...