Math / table / matrix-question

Hello everyone,

first of all: it is not an indesignscripting - but general math-javascriptquestion. Please be patient

I have a first (matrixlike-) table (will not change)

var = [] containers
'container11', 'container12', 'container13', 'container14', 'container15 ',.
'container21', 'container22', 'container23', 'container24', 'container25 ',.
'container31', 'container32', 'container33', 'container34', 'container35 ',.
'container41', 'container42', 'container43', 'container44', 'container45 ',.
'container51', 'container52', 'container53', 'container54', 'container55 '.
];

and I have a second table:

["container14", "container25", "container34", "container44", "container54"] //this array may contain 3 up to 8 items

My goal is to check if a 5 to 3 points in the second array is part of where equal to a row or column of the matrix-like-table.

For example: 'container34', 'container44', 'container54' or 'container11', 'container12', 'container13', 'container14' (in the context of the second table) would be a result I #m you are looking for. Note: I just want to find the 'tax to the largest!

Hope it becomes clear and one of math-cracks will have an idea.

Excess: there is no DUTY to work with arrays. I can also store the data to an object or a mixture... and can fill with numbers instead of strings...

To get visible:

https://DL.dropboxusercontent.com/Spa/3ftsuc9opmid3j4/exports/fourWins/fourWins.html

Items can slip and fall. After every dropp the berries should be compared... and I #m looking for a nice and elegant solution

Maybe someone is interested

Hans

Hello Hans,.

Just a little note well that your issue is resolved.

As long as your matrix is 5 × 5 you can easily map any element into a single character throughout {A, b,..., Z} (for example).

Then your problem can be reduced to a pattern match algorithm, i.e. to find the longest part of the input string in a 'flat' string that concatenates simply lines and columns of the matrix search namely ROW1. ROW2...| Col1| COL2... | Col5

And you can create a RegExp on the fly to calculate the solution (s) with almost no effort:

const MX_ORDER = 5;
const MIN_MATCH = 3; // We need at least 3 contiguous items

var bestMatrixMatch = function F(/*str[]*/ROWS, /*str*/ND)
//--------------------------------------
// NB: No check is made on ROWS, so make sure you supply
//     MX_ORDER strings, each being MX_ORDER-sized
{
    // Put in cache some subroutines
    // ---
    F.RES_TO_STR ||(F.RES_TO_STR = function()
        {
            return localize("'%1' found in %2", this.result, this.location);
        });
    F.ROWS_TO_HS ||(F.ROWS_TO_HS = function(R, C,i,j)
        {
            for( i=0,C=[] ; i < MX_ORDER ; ++i )
            for( C[i]='',j=0 ; j < MX_ORDER ; C[i]+=R[j++][i] );
            return R.concat(C).join('|');
        });

    // Vars
    // ---
    var haystack = F.ROWS_TO_HS(ROWS),
        candidates = ND &&
            haystack.match( new RegExp('['+ND+']{'+MIN_MATCH+',}','g') ),
        t, p;

    if( !candidates ) return null;

    // Sort the candidates by increasing size
    // ---
    candidates.sort( function(x,y){return x.length-y.length} );

    // Grab the matches and keep the best
    // ---
    while( t=candidates.pop() )
        {
        if( 0 > ND.indexOf(t) ) continue;
        p = 1+~~(haystack.indexOf(t)/(1+MX_ORDER));
        return {
            result:   t,
            location: (p<=MX_ORDER)?('Row #'+p):('Col #'+(p-MX_ORDER)),
            toString: F.RES_TO_STR,
            }
        }
    return null;
}

// =================
// Sample code
// =================

var rows = [
    "ABCDE",
    "FGHIJ",
    "KLMNO",
    "PQRST",
    "UVWXY"
    ];
var needle = "EKLMINSX";

// get the result
// ---
var result = bestMatrixMatch(rows, needle);
alert(
    "Searching the longest part of '" + needle + "' in:\r\r" +
    ' '+rows.join('\r').split('').join(' ') +
    '\r\r===============\r\r' +
    (result || "No result.")
    );

@+

Marc

Tags: InDesign

Similar Questions

  • generate the math table in a SQL

    How can I get math tables in a SQL query.

    for taking the table of 2 to 5, you can use

    Select 2 * rownum "table 2", 3 * rownum "table 3", 4 * rownum 'table 4', 5 * rownum 'table 5' from dual connect by rownum<>

  • How do I get the table/matrix of an image?

    Hi, at work we will develop a program that works with images. My question is how can I get the matrix or matrix of pixels in an image?

    Thank you.

    If you have IMAQ there is a picture of table VI

    If you do not have the IMAQ stuff, there is a picture in table VI in the Vision Toolkit free AD: http://vi-lib.com/

    [edit: Oops, missed the last line of your post there are EmcV]

  • Mapping the table matrix 2D

    I can't try to plot the graph of an output matrix, Sk since a MathScript node.

    The Sk parameter should be a way out of the matrix (12 x 1) with the length of the added step.  I can see that its fate in the form of a table 3D but can not get the graph of the function works.

    What I aim to do...

    I need to draw responses to the 12 line separate items of the Sk parameter over time.  This means that I have to post 12 separate parcels, ideally to be on the same graph with a shift on the value axis for stacking the answers (I'm not worried about the relative amplitudes since I was only interested in seeing the step responses in 12 plots).

    If someone can provide some guidance it would be greatly appreciated.

    Just right click on the tunnel exit SK and select data type "matrix of 1 d, DBL.

    (The way you slice the table at the beginning is crazy.) Why do you want to create all copies of these data for the most part redundant? Simply no autoindex on 2D and table use the table to index resized to five outings and wire the first clue to the final iteration to get five tables 1 d. You must also calculate the value connected to N for the number of columns minus four, or similar)

  • design of table size question of data modeling

    Hi Experts,
    Sorry if I put my question in a wrong forum please suggest an appropriate forum.

    need your opinion on the current design of our data warehouse of 10 years.
    There is a dimension table with the structure as follows

    Dimension table
    --------------------
    Number of dimension key (THIS IS NOT a PRIMARY KEY)
    Natural key (from source) number
    the source name character
    current record indicator e Char (1)
    date of form_date
    TO_DATE date
    several other columns, which, if change a new current record is created and the previous one is marked as H-historical

    Data are stored in the table of size like this
    Dimension_key natural key Source name current record ind from_date to to_date
    1 10001 Source1: 1 January 2005 May 31, 2005
    1 10001 Source1: 1 - jun - 20005 12-dec-2011
    1 10001 Source1 C 13-dec-2011 NULL

    2 20002 Source1: 1 - jun - 20001 12-dec-2011
    2 20002 Source1 C 13-dec-2011 NULL

    The problem I see in this design is that if any attribute is changed there is no surrogate key, the new record is inserted first taking the key dimension based on the (natural_key, source_name, current_record_ind).
    Shouldn't it be kept as follows based on the principles of data warehousing.

    Dimension_key natural key Source name current record ind from_date to to_date
    1 10001 Source1: 1 January 2005 May 31, 2005
    2 10001 Source1: 1 - jun - 20005 12-dec-2011
    3 10001 Source1 C 13-dec-2011 NULL

    4-20002 Source1: 1 - jun - 20001 12-dec-2011
    5 20002 Source1 C 13-dec-2011 NULL

    Please let me know the advantages and disadvantages of the current design.

    Published by: Rous Sharma on December 15, 2011 20:28

    Correct, your second example for example by using a surrogate key is design to go with.

    Flaws with the original design:

    -There is a relationship one between Dimension_Key and Natural_Key, no need to keep both.
    -Si Dimension_Key is the FK with a fact table, there will be a number of many relationships between fact and Dimension.
    -Additional processing to search for Dimension_Key rather than simply for example use a sequence.

  • The number of tests table PCQ Questions

    Hi guys,.

    Where can I find (IOM 9.1.0.1 tables) the amount of questions of users trying to do?

    Thank you for your attention,
    Thiago Leoncio

    USR_PWD_RESET_ATTEMPTS_CTR

    It's exactly what you want.

    Just try and see its result.

    But once a successful connection it resets the counter.

    Suppose that you forgot your password and you want to change this password using PCQ.

    Now when you click on five-year plan link so if you gave wrong answer it then it increase the counter (USR_PWD_RESET_ATTEMPTS_CTR) to 1

    Assume that once again if you try with wrong answers it increase to counter (USR_PWD_RESET_ATTEMPTS_CTR) 2.

    But after a successful login, it resets the counter (USR_PWD_RESET_ATTEMPTS_CTR).

    USR_PWD_RESET_ATTEMPTS_CTR you can get a tent PCQ.

    For any other details, did you see System Configuration in the console design?

  • creating a table/average question

    I'm new to labview and I have problems to understand how to create a table.

    I use an Arduino Uno as my DAQ and when I take an anolog measure I've seen a lot of fuctuation to my measure. I know with arduino, you can perform with an average simple by using the function "Get a finished sample of Analog", but I know that I not be using an Arduino in the long term and trying to figure out the right way to do it.

    When I have on average with the Arduino IDE I usually code that looks like this:

    float analogsum = 0;

    for (int i = 0; i)< 10;="">

    analogSum += analogRead (analogPin); where analogRead converts the analog value to a value\ digital 10-bit

    }

    average = analogSum/10;

    I am trying to create this same feature in LabView. The only way I can imagine the analog value of each iteration, in summary would be to store each value in a table, then add them together and divide by the number of iterations in my loop for.

    How would I do this in Labview?

    Hi awwende,

    show all 3 suggestions above:

    You really should go LabVIEW101 the ni.com site to learn the fundamentals of LabVIEW!

  • Table footer question


    I work on the automation of the tables through a publication and I wonder if there is way to create a footer line that appears only on the last page that extends on a table. Any help with this would be awesome! Thank you!

    This isn't one of the options in the dialog box options Table of headers and footers. You can have it appear in the column of text, each Frame, or every Page. I would say simply by putting the footer information into the last row of the table and setting is not like a real page.

  • To loop through the table (newbie question)

    Hello

    I've read and read but can´t seem to do what I want to do.

    I do a lot of forms in Livecycle, but can´t seem to understand even the easiest loop.

    Let's say I have a table with two columns and ten rows. TextFields in column A is called Cell1 and Cell2 B column.

    I want to look through all the lines for that:

    If (Cell1.rawValue! == null)

    Cell2.fontcolor = "255,0,0";

    on the other

    Cell2.fontcolor = "0,0,0";

    If anyone can help me with this, I would be very happy. Mayvbe I can begin to understand this, because it seems that I m missing certain functions very practices.

    / Anders

    Sweden

    Assuming that all your lines are named 'Row ':

    for (var a=0;a
    

    Kyle

  • table join question

    I have two tables joined via a pk/fk relationship. The main table has a field that indicates if a person entered the House (that's a request for home detention for minors) and to the left, or if it is still in the House.

    1 = entered and left, 0 = always in the House.

    The two tables are related through three fields (ID of the person, House ID, date of entry in the House)

    I need a query to retrieve the records that exist in table 1 (the master) but do not exist in table 2 (retail) for (young) people who are STILL in the House. I need the query to run on the House n ° 2.

    I tried a number of relationships to join, but none has been successful.

    Any ideas on how to write this request will be appreciated.

    The next time after table descriptions...

    I think you're asking something like that:

    select pt.*
    from parent_table pt
    where pt.field = 0
      and pt.home = 2
      and not exists
      (select 'a child row for this parent row'
       from child_table ct
       where ct.person = pt.person
         and ct.home = pt.home
         and ct.entry_date = pt.entry_date);
    
  • temporary table unanswered question

    Temporary tablespace issue
    I worked on tablespace temp for the last 4 days some of the question which are not clear about the temporary space
    (1) why is it that for optimal performance, the UNIFORM SIZE must be a multiple of the parameter SORT_AREA_SIZE if SORT_AREA_SIZE 4 m and ONE SIZE 32 m what impact on the reason for the performance
    (2) can be used in10g retractable or 11 g for the temp tablespace command
    (3) MAXSIZE UNLIMITED when I put this time deposited 32 GB it triggered error. Unlimited average as long as physical space is available it must measure but that's not why this limitation. It is the only one associated with the file temp or same problem occur if the data file size 32 GB?
    (4) if I know that my application to do a lot to sort out what is the best way to set up the temporary tablespace so that I don't up space error finished
    (5) ORA-01652: unable to extend temp by 4096 segment in tablespace TEMP this error occurs when I load the data using my application
    Please help in this regard, I am very grateful to you

    Adeel,
    I know VERY less, probably less when it comes to this forum. I know that just O of Oracle.I can not tell how long you take to learn Oracle as it depends on many things, how you study, focus, practice and above all, how much less you think you know. Because I meet a lot of people who think they know too that leaves no space for an extra addition of knowledge :-). I know really very low.

    If I use the LARGE folder to create a temporary space that doesn't solved my problem because I just read in the documentation if your block size is 8 k and OS 32-bit Platte basic form, you can size of 32 TB file. Using this approach I can fix this error condition
    Yes, bigfile can ovecome your space issue. But that could be cure a symptom. The real problem, is that why you do so much sorting that is not able to accommodate itself in memory and is traded on the disk. You should check with your queries and see if you can avoid some unnecessary sorts or things PGA.
    HTH
    Aman...

  • Join table newbie question

    Hi all

    I am pretty new to SQL and need assistance from base on accession to these queries.

    I have a query:

    Select lower (user_name) with users;

    and another:

    Select lower (us.username), max (TIMESTAMP)
    of sys.dba_audit_session us
    where lower (us.username) in (select u.user_name from users u)
    Lower group (us.username);


    Query 1 returns now a lot more results than query 2, but I would like to join the username column of the query 1 and 2, while showing the timestamp for users where it exists.

    Any help appreciated

    something like this (statements are just to simulate your data)

    WITH u AS (SELECT 'Bob' username FROM DUAL
               UNION ALL
               SELECT 'Fred' FROM DUAL
               UNION ALL
               SELECT 'Mary' FROM DUAL
               UNION ALL
               SELECT 'Sandy' FROM DUAL),
         us AS (SELECT 'MARY' username, SYSTIMESTAMP tmestamp FROM DUAL
                UNION ALL
                SELECT 'BOb', SYSTIMESTAMP + 1 FROM DUAL
                UNION ALL
                SELECT 'BOB', SYSTIMESTAMP + 2 FROM DUAL)
    
      SELECT LOWER (u.username), MAX (us.tmestamp)
        FROM us RIGHT OUTER JOIN u ON (LOWER (u.username) = LOWER (us.username))
    GROUP BY LOWER (u.username)
    
    LOWER(U.USERNAME),MAX(US.TMESTAMP)
    mary,10/12/2010 9:41:56.926106 AM -04:00
    bob,10/14/2010 9:41:56.000000 AM -04:00
    sandy,
    fred,
    
  • Impossible to get Graph.DataSource to work in WPF, I (thread question?)

    My chart is work beautifly when I use:

    chartCollection.Append (measure. GHz, measurement.dB);

    But when I try to use this call to the same method, I get nothing on the graph:

    Double data = new double [256];
    ....
    Graph DataSource = data;

    I know not if there is a suspicion, but I declare chartCollection on the main thread, and then pass it on to a different thread to collect data and it draw in real time.

    I could have lived with chartCollection.Append but in this case, I got a lot of data instanteneusly and I want to assign to chart at a time.

    Moreover, it seems that you need about 350 ms differ between each card. Add to not cause exception... but in my case I need to delay in all cases (for data) is not a problem.

    Thank you!

    I'm not very clear on how you mix the table/matrix updates. Here is an example of chart queue adds via the dispatcher (using a class task and assistance as a quick way to simulate the substantive work). You can use any delegate with the dispatcher, so you can assign DataSource in a delegate instead of use the method append on a collection of table.

    public partial class MainWindow : Window {
            private readonly ChartCollection chart = new ChartCollection( );

    public MainWindow( ) {
                InitializeComponent( );

    this.graph.DataSource = chart;

    var worker = new Worker( this.Dispatcher, chart.Append );
                Task.Factory.StartNew( worker.DoWork );
            }

    private class Worker {
                private readonly Dispatcher dispatcher;
                private readonly Action append;

    public Worker( Dispatcher dispatcher, Action append ) {
                    this.dispatcher = dispatcher;
                    this.append = append;
                }

    public void DoWork( ) {
                    for( int i = 0; i <= 360;="" ++i="" )="">
                        double value = Math.Sin( i * Math.PI / 180 );
                        this.dispatcher.BeginInvoke( this.append, i, value );
                        Thread.Sleep( 100 );
                    }
                }
            }
        }

  • Table optimizatioin of construction

    I suspect that my table/matrix construction begins to inhibit data collection. I'm currently collecting spatial data of the image. To collect spatial data of the pannel (gui) before I am establishing data of bad coordinate of a XY Chart with a background image. The sub vi reportoire start tent to prepare the Cartesian coordinates to set motion in the scene.

    How can I accumulate more effectively X, Y/horizontal, vertical/coordinate/pixel location etc. information of a given image. In this vi I try to do it by building a table with data from bad. The Zth deminsion can be moved.

    Thank you very much

    I changed to aray of writing in a file which I think works well. A bit of trouble with my table zth but resolved question.

  • Reverse and pseudo inverse Matrix on FPGA

    Hi all

    How can I calculate matrix inverse/pinv on pushed more logical clock (*.gcdl), for FPGA? (Labview Comms 2.0)
    Maybe someone has a solution for this task? Or that the best algorithm I use for this task?

    Thank you.

    Hello togoto,.

    We have matrix Inverse and matrix screw Pseudo-inverse for code side host, but these are not supported on FPGA. The reason for this is because without a known matrix size, there is not a way to implement a dynamic matrix math function (the compiler couldn't know how many resources which requires). If we consider that more algorithms of inverse depend on the division, which is very intensive on FPGA resources, which provides another reason why we would be unable to put implementation in CDL.

    That being said, Comms has Matrix multiply and transpose the matrix of features that you can implement in CDL. Because for a long time the matrices are always a fixed size and uniform, you can implement a custom algorithm to achieve pseudoinversion and matrix inversion. It would take careful pipelining to ensure it worked in a single clock cycle.

    Could you elaborate on what exactly the application is supposed to accomplish? If possible, the math movement matrix your screw host-side may be the best approach.

    Best,

    Daniel

Maybe you are looking for

  • How to create an equation average. If looking for a range of time?

    Let's get this out of the way: numbers 3.6.1 on a MacBook Pro of retina. I have run activities which start time randomly all day, at various periods of 15 minutes (10:00, 10:15, 10:30, etc.)  Every day have sessions starting at different times, accor

  • Communicate via PIO

    Hello I'm using LabView 8.5 to control a device. The device has a PIO interface that is connected to a card NI PXI 6508 whitin a chassis PXI-1000 b. I try to communicate with the device, but cannot. Y at - it a tutorial that show me the procedure? Th

  • Unexpected computer shutdown

    Windows has suddenly closed without warning 3 times. Started in normal mode. Do you have an antivirus network san. There is no problem. What other shoulod do?

  • Another question "error 40."

    We have the same problem as gardeneva for a fix Access 2007 to Oct 2008 (cannot download, error 40).  Curiously, you can download the file only if change us the default location ("C:\ ") and download only on the desktop.  But then we get an error tha

  • NAT traversal broken after upgrade to 7.04

    We had the work of nat crossing very well on our PIX Bundle of 515e run worm 6.3.4 For ah, esp, iskmp, in the port udp 500. crossing of nat enabled. Sysopt permit-ipsec. behind the pix, users can estrablish vpn connections, but traffic does not pass.