Jump to content
Sign in to follow this  
forbade

matrix_beta

Recommended Posts

forbade

This is my first custom function that I thought would be worth while to share.

& I haven't taken the time to see if anyone else has done, something simular.

 

Alright we have a lovely feature called repeating fields, ( technically they are arrays P: ) but I wanted to know how to implement a matrix in file-maker. I sat down and figured out the math to take a linear array aka repeating field and have it function as a matrix for fun things that matrix doos. I am not a math guy btw, so if the terms that i use are technically wrong then thats why.

 

ok. This will work with any size matrix, NxN ...

 

I am not good at explaining things so, just check the example file.

 

 

--

cfNAME = Matrix //very exciting...name isn't it.

 

Parameters: ( row , column , base , field )

 

Code:

 

Let (

[

r = GetAsNumber ( row ) ; // [N,n]

c = GetAsNumber ( column) ; // [n,N]

b = GetAsNumber ( base ) // this is the number by which the matrix is defines... defines how deep the matrix goes :D

] ;

 

(

 

Case (

r = "1" ; Let ( rep = (( b - b ) +c ) ; GetRepetition ( field ; rep ) ) ; // (( b -b ) +c )

r > "1" ; Let ( rep = (( b * ( r - 1) ) + c ) ; GetRepetition ( field ; rep ) ) //

; "please check the base number for your matrix"

 

)))

Share this post


Link to post
Share on other sites
Ender

Greetings forbade, and welcome to the world of CFs!

 

It looks like what you have is essentially a method to access a repeating field value, where the repeating field is broken up into multiple virtual rows.

 

I think where matricies really get useful is for passing arrays or for mathematical transformations. For these, I think it's more useful to have a dynamic structure, with spaces (or some other separator) to separate columns and returns to separate rows, all within a single text value.

 

Why this structure? There is already a good set of functions for assembling and parsing strings of data by word and by line. For example, if you want a "matrix" of values based on a field in a portal, you could use the List() function (FM8.5 or later) to grab the related rows and put them in a return separated list. Multiple values can be easily be appended into a single row with multiple columns by using the old amperstand:

 

row = field1 & " " & field2 & " " & field3

 

Similarly, rows can be extracted with GetValue(), and columns within a row can be identified with MiddleValues(). So if you want a particular cell (x,y) within a matrix, you could use something like:

 

middlewords(getvalue(matrix; x); y; 1)

 

Of course, if you're dealing with text values, you probably need a different column separator and adjust the calcs accordingly.

 

To add a little power on a higher level, you might have a set of CFs to insert values and access values in various "cells" within the grid, and if you're mathematically inclined, CFs to apply transformations to the matrix.

Share this post


Link to post
Share on other sites
forbade

thanks for the advice ender, mucho apreciado.

 

when i got home last, night I actually came to the same conclusion about having a function to insert values too. I think ill play around with this for a while and come back when I have a more solid method for matrix manipulation :) and thanks again for the advice.

 

peace

Share this post


Link to post
Share on other sites
This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



×
×
  • Create New...

Important Information

Terms of Use