Jump to content

Recommended Posts

FMS

Hello,

The last couple of day's I was searching on this forum for the best way to put array's inside array's.
The best example's i found where a little outdatet (2010) whit a lot of pro's and con's.

Now I've a big script where a lot of computations and big array's are involved, so speed is a big issue.
Also I wanna try the script below but don't know iff speed is a problem this way or maybe there is a better way to do this.

Does somebody know's the best way to put array's inside array's and get the data back from them?
I've made an example of something I was thinking about.
(maybe something totaly wrong but I'm open for sugestions)

I'm doing it this way because I don't think I can access the data inside the array (and doing some calculations to it) some other way if the array is inside another array.
Or is there?

Thanks in advanced.

#include <Array.au3>

Global $aArray[Random(5,10,1)][Random(5,10,1)]
Global $Holder[2][2]

For $x = 0 To UBound($aArray,1) - 1
   For $y = 0 To UBound($aArray,2) - 1
      $aArray[$x][$y] = Round(Random(-1,1),4)
   Next
Next

$Holder[0][0] = $aArray
$aArray = ""
Global $get_array = $Holder[0][0]

_ArrayDisplay($get_array)

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
iamtheky

So if you filled a 2x2 array with other 2d arrays, this is how you would call the item in 0,0 of each of those elements. 

#include <Array.au3>

Global $aArray[Random(5,10,1)][Random(5,10,1)]
Global $Holder[2][2]

For $w = 0 to ubound($Holder) - 1

    For $x = 0 To UBound($aArray,1) - 1
       For $y = 0 To UBound($aArray,2) - 1
          $aArray[$x][$y] = Round(Random(-1,1),4)
       Next
    Next

    $Holder[$w][0] = $aArray

    For $x = 0 To UBound($aArray,1) - 1
       For $y = 0 To UBound($aArray,2) - 1
          $aArray[$x][$y] = Round(Random(-1,1),4)
       Next
    Next

    $Holder[$w][1] = $aArray

Next




msgbox(0, '' , ($Holder[0][0])[0][0])
_ArrayDisplay($Holder[0][0])
msgbox(0, '' , ($Holder[0][1])[0][0])
_ArrayDisplay($Holder[0][1])
msgbox(0, '' , ($Holder[1][0])[0][0])
_ArrayDisplay($Holder[1][0])
msgbox(0, '' , ($Holder[1][1])[0][0])
_ArrayDisplay($Holder[1][1])

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
jchd

If the context demands storing 2D arrays inside 2D arrays, I see no other better way than your initial post. But maybe your problem can cope as well with a single 4D array; that would make accessing individual elements much faster.

The drawback being that you can't store variable dimension arrays when "mapped" as individual elements of a larger-dimension array. You then need to use the maximum dimensions of all the inner arrays. This isn't an issue if you store arrays inside arrays.

Perhaps there is a better solution if you expose more of the context you're working in.


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)

Share this post


Link to post
Share on other sites
RTFC
13 hours ago, FMS said:

a lot of computations and big array's are involved, so speed is a big issue

If so, I would suggest you do not use arrays at all (and certainly not nested arrays!), but matrices instead.

  • Like 1

Share this post


Link to post
Share on other sites
jchd
4 minutes ago, RTFC said:

If so, I would suggest you do not use arrays at all (and certainly not nested arrays!), but matrices instead.

That's a good possibility thanks to your hard work on Eigen, but only if the actual problem semantics is in some numerical domain, something we have little clue about. Tensor calculus may reveal non-trivial.

It all depends on the task to perform.


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)

Share this post


Link to post
Share on other sites
RTFC

@jchd: of course, agreed (and thanks), but the OP suggested a typical case of XYProblem to me, and the twin requirements of "large data sets" (>17M cells? then forget AutoIt arrays altogether) and "lots of computations" just cries out (in my myopic perception of the barely-defined actual problem) for a matrix approach. In any case, a deferred pointer-to-pointer-to-pointer structure (i.e., nested multidim arrays) would seem to me anathema to the aforementioned two stated requirements. Whenever my contexts require 2D nesting (very, very rare), I just tile a large 2D matrix with smaller ones, and use block-based access. Anyroad, I just wanted to flag the possibility of another possible method that might be of use.:)

Share this post


Link to post
Share on other sites
jchd

You're correct. Let's see how the OP describes his real-world problem and the nature of the computations needed.

You know that unfortunately most users aren't too much math-inclined.


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)

Share this post


Link to post
Share on other sites
FMS

In the past I found the eigen UDF, this because I'm tryng to make an AI (code below (working but not finished)) whish is calculating whit matricies a big plus. @RTFC
unfortunaly When i tried to inplement it , it was a litle confusing for me because I'm not that great in matricies-> math :S
Also din't know how to calculate whit the eigen UDF to do what i want.
That's why i tried to do the same only whit array's.

(does this seems like an XY-problem? :)
 

 

AI.au3

t10k-images.idx3-ubyte

t10k-labels.idx1-ubyte

settings.set

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
RTFC

@FMS: Thanks, that's a lot clearer.:) Cursory inspection of your code tells me you're building a neural net with two hidden layers, in order to associate labels with images. AFAICT, the math involves basic matrix arithmetic and one exponential function (so nothing E4A cannot handle out of the box). Of course, it's entirely up to you whether you'd want to invest the time to refactor your code in matrix terms (I'm of course not going to do this for you;)), but all those nested loops over 2D arrays you've got now would be gone (each one replaced by a single E4A call), and the computations themselves would be machine-code (dllcall), not AutoIt. But for getting to grips with neural nets, it might be more instructive to stick with pure AutoIt, so you can see what happens at every stage. However, I fear your design won't be fast enough to solve difficult (read: large) problems (myself, I would probably solve classification problems like yours with _Eigen_LDA, or identify the relevant independent sources of variability in the images first through _Eigen_PCA, but that's just me; read the online Tutorials on these functions if you're interested, or study the provided Tutorial scripts; they use different projections into eigenspace; maybe not your cup of tea).

Just thought that if you hadn't been aware of E4A at all, it would have been worth considering (no size limits on inputs, and blazingly fast). Never mind.:(

One suggestion though. That generic "normelize" function you're using, which Executes whatever expression is fed to it is needlessly slowing down your code no end. Id' write dedicated functions for each usage case, and parse only parameters and/or ByRef arrays to them.

Veel succes ermee, in ieder geval.

Edited by RTFC
typos

Share this post


Link to post
Share on other sites
FMS

Bedankt voor je antwoord @RTFC :D ,

The code I provide in the earlyer post , was me building an AI on pure autoit to get the a grip on AI.
Afther I get the grip I was refactoring it anyway :)

1st I want to have it working ;)

If I had it working corectly I wanna try the it whit matricies.
This because I don't know how to do and did have the time to get an grip on matricies :D

The study of the examples in eigen i did before (for the sigmoid ;) )  and was indeed not mine cup of tea.

Quote

(I'm of course not going to do this for you;))

Ofcourse I don't want to ask you that :) , just for 1 thing -> I want to know what is going on under the hood, and that way I don't :)

But could you give an basic example on whish i can build on it ? (preferbly the calculations i need)

At this point I want to implement matricies calculations (because google says that's the best way) but I realy don't know how.

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
RTFC
17 minutes ago, FMS said:

1st I want to have it working

Very sensible; I'd do it that way too.

18 minutes ago, FMS said:

I want to know what is going on under the hood, and that way I don't

If you've downloaded the E4A package, you'll have noticed there's a subdirectory called source, where you'll find the complete C++ code of the (real float part of the) dll. In addition, you've  got the AutoIt wrapper code (Eigen4Autoit.au3),  Eigen's own website + documentation (with lots of simple examples) + forum, plus my own extensive online Help, where every function description includes an example script, just like AutoIt's Help. In your case, I would start by studying the Cwise (cell-wise) functions, as they provide most of what you'll need.

For a basic introduction to matrix math, I recommend the Khan academy's videos as a starting point. That should be enough to get you going.

Share this post


Link to post
Share on other sites
FMS

I'm getting a little off topic on this thread but I'm refactoring the code at this point to use Eigen4Autoit.au3.
And I must say,.... it's easyer then i first thought :)
good work on the documentation @RTFC, it's very clear :)

A whole lot of code replaced by (and more to come :) ) :

_Eigen_Multiply_AB_plusC($M_weights_ih1,$M_Ninputs,$M_bias_h1,$M_outputs_h1)

I'm now at the point of  "activate" the $M_outputs_h1 , whish i did before in the array whit

For $x = 1 To UBound($outputs_h1,1) - 1
    $outputs_h1[$x][1] = sig($outputs_h1[$x][1])
Next

Func sig($x)
   Return 1 / (1 + exp($x * -1))
EndFunc

I'm a little confused to do multiple calculations on an 1 colum matrix in 1 go.
Is this even possible?
The code below uses multiple columns.

$rows=101
$matA=_Eigen_CreateMatrix($rows,3)
_Eigen_SetLinSpaced_Col($matA,0,-10,10)
_Eigen_CwiseUnaryOp_ColCol_InPlace($matA,0,1,"exp")
_Eigen_CwiseScalarOp_ColCol_InPlace($matA,1,2,"+",1)
_Eigen_CwiseBinaryOp_ColCol_InPlace($matA,2,1,"/",$matA)
_matrixDisplay($matA)

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
RTFC
1 hour ago, FMS said:

And I must say,.... it's easyer then i first thought :)
good work on the documentation

Great, glad to hear it.^_^

1 hour ago, FMS said:

'm a little confused to do multiple calculations on an 1 colum matrix in 1 go.
Is this even possible?

Absolutely.:yes: A matrix with one dimension of unity is usually called a vector, but for simplicity, everything in E4A works with matrices as basic entity. And the functions are simpler when they act on each cell of the entire matrix, because you don't need to identify which row or col is used. Look at the brackets in your sig function and work from the inside out. Maybe something along these lines (not tested!):

_Eigen_CwiseScalarOp_InPlace($matA,"*",-1)  ; multiply by -1
_Eigen_CwiseUnaryOp_InPlace($matA,"exp")    ; apply exponential function
_Eigen_CwiseScalarOp_InPlace($matA,"+",1)   ; add 1
_Eigen_CwiseUnaryOp_InPlace($matA,"inverse")    ; obtain 1/x

 

Share this post


Link to post
Share on other sites
FMS

:drool: nice , why din't I tried it before.
So less code for doing the same thing whit better performance!!

@RTFC aso big tumps up on the " _Eigen_SaveMatrix " and " _Eigen_LoadMatrix " !!!
This makes life so mush easyer :)

At this point I'm refactoring the dsig function whish I did before like this :

For $k = 1 To UBound($error_o,1) -1
    $dsig_o[$k][1] = dsig($outputs_o[$k][1])
Next


Func dsig($x)
   Return $x * (1 - $x)
EndFunc

I tried to do it like this. (And din't give the expected result :( )

$M_grad_o = _Eigen_CloneMatrix( $M_error_o , False )
_Eigen_SetOnes ( $M_grad_o )

_Eigen_CwiseScalarOp_InPlace( $M_grad_o ,"-",$M_error_o)
_Eigen_Multiply_AB_InPlace ( $M_grad_o, $M_error_o )

_MatrixDisplay ( $M_grad_o , "$M_grad_o" )

I'm a little stuck in this part , and feel like I'm doing this whole wrong.
Also I think I'm doing this to complex and there is an easyer way , am I wright?


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
RTFC

Classic mistake, easy to make. You're confusing scalar cellwise multiplication with matrix multiplication. Use _Eigen_CwiseBinaryOp_InPlace with operator "*" (or alias "mult") instead. Also see this video, to understand why it failed before.

Edited by RTFC

Share this post


Link to post
Share on other sites
kylomas

RTFC & FMS

I watched the video and understand the concept (no math background) but do not understand the practicality of it.   Can you give a real life example of matrix math?

Thanks,

Kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
FMS

@kylomas For me -> If you look at AI.au3 and specificly at the function "feed" whitin, there are a lot of computations whis are the same across the whole array.
This I'm refactoring now to use E4A.

1 reason for performance and the other for not to use loops.

Maybe not the best explanation :) I'm also not an math-wizzard but I like the simplicitie.
 

Func feed($runtimes = 10 , $backward = False)

   $feed_forward = True
   rap_rebuild_global($runtimes)

   If $backward Then $feed_backward = True

   If $GUI Then
      If $may_update_GUIdata Then
         GuiCtrlSetData($GUI_inp_correct , 0 )
         GuiCtrlSetData($GUI_inp_wrong , 0 )
      EndIf
   EndIf

   Local $treshold_counter = 0
   For $x = 1 To $runtimes

      If $backward Then $settings[24][1] += 1
      $settings[23][1] += 1
;~ cw("$settings[23][1] = " &  $settings[23][1])
      If $settings[23][1] > UBound($raw_target,1) - 1 Then $settings[23][1] = 1

      If $GUI And $feed_gui_settings Then GuiCtrlSetData($GUI_inp_total_runs , $settings[23][1] )

      $treshold_counter += 1
      If $treshold_counter > $treshold_counter_max Then
         $treshold_counter = 0
         Sleep($treshold_time)
      EndIf

      set_new_input()
      feed_forward()
      rap_report($x)
      If $backward Then feed_backward()

   Next


   $feed_forward = False
   $feed_backward = False
   rap_calculate($runtimes)

   ad($results,"$results" ,True)
EndFunc


 

Func feed($backward = False)
   normelize_input()
   $M_Ninputs = _Eigen_CreateMatrix_FromArray ( $A_Ninputs, True )
   _Eigen_Multiply_AB_plusC($M_weights_ih1,$M_Ninputs,$M_bias_h1,$M_outputs_h1)
   _Eigen_CwiseScalarOp_InPlace($M_outputs_h1,"*",-1)
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_h1,"exp") 
   _Eigen_CwiseScalarOp_InPlace($M_outputs_h1,"+",1) 
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_h1,"inverse")

   _Eigen_Multiply_AB_plusC($M_weights_h1h2,$M_outputs_h1,$M_bias_h2,$M_outputs_h2)
   _Eigen_CwiseScalarOp_InPlace($M_outputs_h2,"*",-1)
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_h2,"exp")
   _Eigen_CwiseScalarOp_InPlace($M_outputs_h2,"+",1) 
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_h2,"inverse") 

   _Eigen_Multiply_AB_plusC($M_weights_h2o,$M_outputs_h2,$M_bias_o,$M_outputs_o)
   _Eigen_CwiseScalarOp_InPlace($M_outputs_o,"*",-1)
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_o,"exp") 
   _Eigen_CwiseScalarOp_InPlace($M_outputs_o,"+",1)
   _Eigen_CwiseUnaryOp_InPlace($M_outputs_o,"inverse")

;~    _Eigen_CreateArray_FromMatrix( $M_outputs_o, $A_outputs_o )
;~    _ArrayDisplay ( $A_outputs_o, "$A_outputs_o" )

   If $backward Then
      set_target()
      $M_target_o = _Eigen_CreateMatrix_FromArray ( $A_target_o, True )
      $M_error_o = _Eigen_CwiseScalarOp ( $M_target_o, "-", $M_outputs_o );==== needs testing

      $M_grad_o = _Eigen_CloneMatrix( $M_error_o , False )
      _Eigen_SetOnes ( $M_grad_o )
      _Eigen_CwiseBinaryOp_InPlace( $M_grad_o ,"-",$M_outputs_o)
      _Eigen_CwiseBinaryOp_InPlace ( $M_grad_o, "*" , $M_error_o )
      _Eigen_CwiseScalarOp_InPlace($M_grad_o,"*",$learning_rate)
;~    _MatrixDisplay ( $M_grad_o , "$M_grad_o" )

;~    $MT_weights_h2o = _Eigen_CloneMatrix_Transposed ( $M_weights_h2o , True )
;~    $M_delta_o = _Eigen_DotProduct ( $M_grad_o , $MT_weights_h2o )
;~    _MatrixDisplay ( $M_delta_o , "$M_delta_o" )

   EndIf
EndFunc

The refactor code isn't finished yet ;)

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
RTFC
1 hour ago, kylomas said:

Can you give a real life example of matrix math?

For simple answers as to why and where matrix math is useful, see for example here, here, and here. Some examples of applications  of linear algebra (which relies heavily on matrix math) are here.

For some practical examples in the current context, see the online E4A Tutorials on fitting a function through points   ("Regression"),  lossy compression ("PCA"), and classifying flower species ("LDA"). See also the intro webpage "Why Bother?" in the online Help. You don't need to download the E4A package, just reading the Tutorials and studying sample snippets should give you the general idea.

Basically, whenever you're dealing with large numerical data sets, casting them as matrices allows you to perform operations on them (or specific parts thereof, like a row, column, or block) in parallel (that is, affecting all cells in one call, but crucially, you don't need a parallel processor or supercomputer to do this). This means that the size of a particular problem no longer matters. For example, ATLAS particle detection at CERN involves terabytes of data, and uses the Eigen library (see Conclusions section in linked paper) to perform the statistics to extract the significant signature of hunted particles.

In your every day programming, if your code contains lots of (nested?) loops iterating over array cells to do any kind of math, it's probably worth investigating whether a matrix approach would be a more efficient alternative. It also helps to turn problems inside out, and there's some neat tricks in matrix land that can save you tons of time.

Share this post


Link to post
Share on other sites
jchd

To add a little bit to what @RTFC just said, matrices are used in a huge number of domains. One of them you are more or less familiar with involves rotation in 2D or 3D spaces. A rotation in those spaces (as well as in higher dimensions) is usefully performed by a single matrix operation. Rotation in spaces beyond dimension 2 is not as simple as it looks like, because composition of 2 rotations there is no more commutative (the result depends on the order in which both are applied). Again a matrix can represent any rotation. Compared to the mess that Euler angles is, this is the winner path, also since matrix rotations in 3D do not suffer from the gimbal lock issue.

Furthermore, one can define a 4x4 matrix to perform a perspective transform of a 3D scene. Knowing it or not, doing so means using quaternions (which also have a matrix representation).


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)

Share this post


Link to post
Share on other sites
FMS

Here is also a real world problem :D

I've the (java) code below whis I'm trying to refactor into E4A.
In the end I need to have "weight_ho_deltas" .

// Calculate deltas
 let hidden_T = Matrix.transpose(hidden);
let weight_ho_deltas = Matrix.multiply(gradients, hidden_T);


  static multiply(a, b) {
    // Matrix product
    if (a.cols !== b.rows) {
      console.log('Columns of A must match rows of B.');
      return;
    }

    return new Matrix(a.rows, b.cols)
      .map((e, i, j) => {
        // Dot product of values in col
        let sum = 0;
        for (let k = 0; k < a.cols; k++) {
          sum += a.data[i][k] * b.data[k][j];
        }
        return sum;
      });

  map(func) {
    // Apply a function to every element of matrix
    for (let i = 0; i < this.rows; i++) {
      for (let j = 0; j < this.cols; j++) {
        let val = this.data[i][j];
        this.data[i][j] = func(val, i, j);
      }
    }
    return this;
}

Where i did before in autoit (whish is totaly wrong i think) :

For $k = 1 To UBound($error_o,1) -1
      $delta_o[$k][1] = normelize($grad_o[$k][1] * $outputs_o[$k][1])
   Next

I'm now trying to do whit :

$M_delta_o = _Eigen_CloneMatrix( $M_weights_h2o , False )
_Eigen_Multiply_ABt  ( $M_grad_o , $M_weights_h2o , $M_delta_o )
_MatrixDisplay ( $M_delta_o , "$M_delta_o" )

whish din't work and then tried :

$M_delta_o = _Eigen_DotProduct   ( $M_weights_h2o , $M_grad_o )

Afther that I tried :

$MT_weights_h2o = _Eigen_CloneMatrix_Transposed ( $M_weights_h2o , True )
      _MatrixDisplay ( $MT_weights_h2o , "$MT_weights_h2o" )
      $M_delta_o = _Eigen_CloneMatrix( $M_weights_h2o , False )
      _Eigen_CwiseBinaryOp( $M_grad_o , "*" , $MT_weights_h2o , $M_delta_o )
;~    _Eigen_CwiseBinaryOp_Rowwise ( $M_grad_o, "*", $MT_weights_h2o , $M_delta_o )
      _MatrixDisplay ( $M_delta_o , "$M_delta_o" )
;or whit :
;_Eigen_CwiseBinaryOp_Rowwise ( $M_grad_o, "*", $MT_weights_h2o , $M_delta_o )

I understand what is going on but don't know how to name it in E4A???

Does somebody know's how to calculate it / name in E4A ?

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • Iceburg
      By Iceburg
      Hi everyone, I'm at best a noobie.  I have read through the Array helps, and specifically the 2D array help file, and I'm struggling to get my code working.
      I have an array that is read from a file, thats working great.  I'm trying to do some math on the array, so I can find the largest, average, lowest, day over day change %, etc.
      The array read working fine, I get 43 lines, line 0 is 44, and then I get data that looks like
      0519 $10,000
      0520 $10,001
      0521 $10,002
      The data in this array is a single 1D array, breaking it out into 2 columns so I can do the math is what I can get to happen.  
      How do I reference the array to store this data?  Second, how do I assign this data to the appropriate row/column?
      Thanks in advance.
      Dim $all_cash_amounts[UBound($aInput)][2] Dim $max_amount_in_account Dim $min_amount_in_account _FileReadToArray($LC_Check_file_path, $aInput) _ArrayDisplay($aInput) local $date = StringRegExp($aInput[1], "(\d\d\d\d)", 1) local $cash = StringRegExp($aInput[1], "\d+\s(-?[0-9\.\,]+)", 1) ConsoleWrite("Date is: " & $date & @CRLF) For $i = 1 To UBound($aInput)-1     $date = StringRegExp($aInput[$i], "(\d\d\d\d)", 1)     $all_cash_amounts[$i][2] = $date[$i][0], $cash[$i][1]      Next _ArrayDisplay($all_cash_amounts)  
    • OldGuyWalking
      By OldGuyWalking
      Given an array with multiple columns that is displayed in a listview,
       ===> What is the fastest/most efficient way to create and manage multiple filters and display results in ListView.
      I have a text file that loads into a listview that has string, numeric, and date columns.  The main file contains about 5100 rows. It's loaded into an array and (in this ListView) it's pre-filtered to display a range of rows based on a start and end date.  On the form I have menu options for various filters. (see below).
      I have options to filter on an "Air Date" column (=Today, >=Today, <=Today) and on a numeric field that is either 1 or 0 that indicate Active or Ended.

      For each filter option I have a prebuilt array that holds a subset of the main array based on a single filter.  For the list above I have the main Array and 5 additional arrays.  None of the arrays are updated since this is for "view only" purposes.  This is a short list and I could have done the filtering "live" but I have several of these forms and so kept the same functionality in each. I have another ListView that displays the complete 5100 row list with 3 filters that, when building the filters live was considerably slower than using prebuilt arrays.
      If I want to expand past simple single column filtering, using an array for each filter becomes cumbersome especially if I want to combine filters using AND & OR.
      The text file I'm working with has 16 columns. If I setup filters for 4 columns and include AND / OR capability that would require prebuilding 24 arrays to cover the various combinations.
      If using the slower method of building a filtered array in real time each time a different filter is selected is the only way to go with this then I'll live with it. It is less overhead. .
      Below is the code I'm currently using to "filter" an array.  My next change was going to add AND / OR functionality (see the info above the header for where I was going with this) .
      ; Description ...: Delete rows from an array and only keep rows that meet the crtieria of identified columns. ; ; Next Change: Add AND/OR to combine filters. Use array to hold multiple criteria and values? ; ; Local $aCriteria[][] = [["",$iColNbr1, $sOperator1, $vValue1], ["AND",$iColNbr2, $sOperator2, $vValue2], ["OR",$iColNbr3, $sOperator3, $vValue3]] ; The first set of criteria ["", $iColNbr1, $sOperator1, $vValue1] must start with a "". ; If anything is entered in that first parameter it will be ignored. ; If the first parameter in any additional criteria set is left blank, or it is not OR, it will default to AND. ; If $aArray is 1 dimension with more than one set of criteria, only the first set will be used. ; Any criteria that uses a column that is less than 0 or higher than the total number of columns in the array will return an error. ; ; Recognized data types for this function are: S (String), D (Date), N (Number). ; ; Recognized Operators are: "EQ", "NEQ", "IN", "GT", "GE", "LT", "LE", "BETWEEN". ; ****** Not all operators work with all data types. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayFilter ; Description ...: Delete rows from an array and only keep rows that meet the crtieria of identified columns. ; Syntax ........: _ArrayFilter(Byref $aArray[, $iCol = 0[, $sOperator = "EQ"[, $vValue = ""[, $iOptionBase = 0]]]]) ; Parameters ....: $aArray - Array being filtered. ; $iCol - [optional] Column to filter. Default is 0. ; $sOperator - [optional] Operator. Default is "EQ". ; $vValue - [optional] Criteria to compare the column/row value against. ; $iOptionBase - [optional] Starting row. Default is 0. ; Return values .: None ; Author ........: OldGuyWalking ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ArrayFilter(ByRef $aArray, $iCol = 0, $sOperator = "EQ", $vValue = "", $iOptionBase = 0) Local $hFunc = _ArrayFilter $vValue = StringStripWS($vValue, 3) If $vValue = "[Today]" Then $vValue = _NowCalcDate() EndIf Local $sMsg Local $sMsgHdr Local $n1 Local $sDeleteIndex Local $aDeleteIndex Local $iCnt = 0 Local $iRows Local $iColMax Local $iDim Local $sData Local $sVType Local $sDType Local $LBound Local $iDiff If $iOptionBase <> 0 Then $iOptionBase = 1 EndIf If _IsValueEmpty($aArray) Then Return SetError(1, 0, "") EndIf $iDim = UBound($aArray, $UBOUND_DIMENSIONS) If $iDim = 1 Then If $iCol <> 0 Then $iCol = 0 EndIf EndIf If $iDim = 2 Then $iColMax = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iCol > $iColMax Or $iCol < 0 Then Return SetError(1, 0, "") EndIf EndIf If Not _IsBetween($iDim, 1, 2) Then ;############### MSG2 - START ############### $sMsgHdr = FuncName($hFunc) & " :Line: " & @ScriptLineNumber & " :Error= " & @error $sMsg = "Invalid Dimensioned Array. Must be a 1 or 2 dimensional array." MsgBox(0, $sMsgHdr, $sMsg) Return SetError(1, 0, "") ;############### MSG2 - END ############### EndIf ; Identify what the value is ; If it is not a String, Int, Number, or Date then skip. Select Case _DateIsValid($vValue) = 1 $sVType = "D" Case IsNumber($vValue) = 1 $sVType = "N" Case IsString($vValue) = 1 $sVType = "S" Case Else ;############### MSG2 - START ############### $sMsgHdr = FuncName($hFunc) & " :Line: " & @ScriptLineNumber & " :Error= " & @error $sMsg = "Comparison value must be a " & @CRLF & _ "1. Date in YYYY/MM/DD format " & @CRLF & _ "2. A string " & @CRLF & _ "3. A number " & @CRLF MsgBox(0, $sMsgHdr, $sMsg) Return SetError(1, 0, "") ;############### MSG2 - END ############### EndSelect $iCnt = 0 For $n1 = UBound($aArray) - 1 To $iOptionBase Step -1 If $iDim = 1 Then $sData = StringStripWS($aArray[$n1], 3) ElseIf $iDim = 2 Then $sData = StringStripWS($aArray[$n1][$iCol], 3) EndIf Select Case _DateIsValid($sData) = 1 $sDType = "D" Case IsNumber($sData) = 1 $sDType = "N" Case IsString($sData) = 1 $sDType = "S" Case Else $sDType = "U" EndSelect If _IsValueEmpty($sData) Then $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop ; $sDType = $sVType EndIf If Not _IsValueEmpty($sData) And $sDType <> $sVType Then $sDeleteIndex = $sDeleteIndex & $n1 & "," $iCnt += 1 ContinueLoop EndIf Select Case $sOperator = "EQ" Switch $sDType Case "D" $iDiff = _DateDiff("D", $vValue, $sData) If $iDiff = 0 Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "S" If $sData = $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "N" If $sData = $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "NEQ" Switch $sDType Case "D" If $sData <> $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "S" If $sData <> $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "N" If $sData <> $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "IN" Switch $sDType Case "S" If StringInStr($sData, $vValue) Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "GT" Switch $sDType Case "N" If $sData > $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "D" $iDiff = _DateDiff("D", $vValue, $sData) If $iDiff > 0 Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "GE" Switch $sDType Case "N" If $sData >= $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "D" $iDiff = _DateDiff("D", $vValue, $sData) If $iDiff >= 0 Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "LT" Switch $sDType Case "N" If $sData < $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "D" $iDiff = _DateDiff("D", $vValue, $sData) If $iDiff < 0 Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch Case $sOperator = "LE" Switch $sDType Case "N" If $sData <= $vValue Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop Case "D" $iDiff = _DateDiff("D", $vValue, $sData) If $iDiff <= 0 Then ContinueLoop EndIf $sDeleteIndex &= $n1 & "," $iCnt += 1 ContinueLoop EndSwitch EndSelect Next If $iCnt > 0 Then _DeleteArrayRows($aArray, $sDeleteIndex) EndIf EndFunc ;==>_ArrayFilter Thanks in advance.
      OldGuyWalking
    • MyEarth
      By MyEarth
      Hello. I have a 1D array. Is made in this way:
      1. This is a line Messages: a message etc Context: a context etc 2. This is a line Messages: a message etc Context: a context etc 3. This is a line Messages: a message etc Correction: a correction etc Context: a context etc I need to make something like:
      1. This is a line|Messages: a message etc|Context: a context etc 2. This is a line|Messages: a message etc|Context: a context etc 3. This is a line|Messages: a message etc|Correction: a correction|Context: a context etc For exporting in another software. I need to split every time there is a number when the line start, can be 1. until something like 3.976. Since i don't know if there a 2 line after a number or 3 i have opened this thread. Thanks
    • FMS
      By FMS
      Hello,
      I'm trying to randomly change some cells in a array on a given percentage.
      at this point I 've a array whit all 0's and want to change some cells to 1.
      I'm not shure how to do this in a good coding sort of way.
      Also maybe there is a build in function whish I'm not aware of.
      Does somebody know how I can do this in a easy way?
      I was trying to get the total count of cells and get the percentage of it.
      And was stuck when i wanna change the cell.
      please advice, thanks in advanced for your help.
      #include <Array.au3> Global $percentage = 0.2 Global $aArray[Random(10,30,1)][Random(10,30,1)] For $x = 0 To UBound($aArray,1) - 1 For $y = 0 To UBound($aArray,2) - 1 $aArray[$x][$y] = 0 Next Next _ArrayDisplay($aArray) randomize() _ArrayDisplay($aArray) Func randomize() Local $total_to_change = ((UBound($aArray,1) * UBound($aArray,2)) / 100) * $percentage ConsoleWrite( "$total_to_change = " & $total_to_change & @LF ) ConsoleWrite( "total in array = " & (UBound($aArray,1) * UBound($aArray,2)) & @LF ) EndFunc  
    • guinness
      By guinness
      #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> ; Proof of concept for using the control id as an index item for an array. I created back on 8th April 2013. Example() Func Example() ; Create the GUI. Local $iHeight = 400, $iWidth = 400 Local $hGUI = GUICreate('', $iWidth, $iHeight) GUISetState(@SW_SHOW, $hGUI) ; Declare variables to be used throughout the example. Local Const $BUTTON_ROWS_COLUMNS = 8 Local Enum $eCTRL_HWND, $eCTRL_VALUE, $eCTRL_MAX Local $aMsg[1][$eCTRL_MAX], _ $iButtonHeight = $iHeight / $BUTTON_ROWS_COLUMNS, _ $iButtonWidth = $iWidth / $BUTTON_ROWS_COLUMNS, _ $iControlID = 0 For $i = 0 To $BUTTON_ROWS_COLUMNS - 1 For $j = 0 To $BUTTON_ROWS_COLUMNS - 1 $iControlID = GUICtrlCreateButton($i & ',' & $j, $i * $iButtonWidth, $j * $iButtonHeight, $iButtonWidth, $iButtonHeight, $BS_CENTER) ; Increase the size of the array if the control id is greater than or equal to the total size of the array. If $iControlID >= UBound($aMsg) Then ReDim $aMsg[Ceiling($iControlID * 1.3)][$eCTRL_MAX] EndIf ; Add to the array. $aMsg[$iControlID][$eCTRL_HWND] = GUICtrlGetHandle($iControlID) $aMsg[$iControlID][$eCTRL_VALUE] = 'Sample string for the control id: ' & $iControlID Next Next ; Clear empty items after the last created control id. ReDim $aMsg[$iControlID + 1][$eCTRL_MAX] ; Display the array created. _ArrayDisplay($aMsg) Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aMsg[$eCTRL_HWND][$eCTRL_HWND] To UBound($aMsg) ; If $iMsg is greater than 0 and between the 0th index of $aMsg and the last item then display in the console. If $iMsg > 0 Then ConsoleWrite('Control Hwnd: ' & $aMsg[$iMsg][$eCTRL_HWND] & ', ' & $aMsg[$iMsg][$eCTRL_VALUE] & @CRLF) EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example  
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.