Using Match on a matrix without loopAll,
Is it possible to use match on matrices ? I dont see from the documentation that this is possible, but has anyone tried this before ? Essentially, here is an example of what I would like to acheieve without a loop. Wish there was more documentation and blog posts for vectorizing matrix operations in JSL.
A = [0.1,0.2,0.3,0.4];
TestMat = [1,2,3,4,4,2,3,1,3,2,4,1];
TestMat1 = J(N Rows(TestMat),1,0);
for(i = 1, i <= N Rows(TestMat), i++,
TestMat1[i,1] = Match(TestMat[i],1,A[1],2,A[2],3,A[3],4,A[4]);
);
Show(TestMat1);
Re: Using Match on a matrix without loop@gzmorgan0,
If you look through the example that you have pointed out, the only thing that is documented in that section is logical indexing. The concept of logical indexing is powerful and one approach of acheiving vectorization of code.
With almost every other language/ analytical platform be it R, Matlab , Python etc. there is tons of documentation and in-built functions that make it easy to write clean, vectorized code. You may already know how to do this, but provided this one limited example on logical indexing, I dont think is particularly efficient to write clean, fast code for all needs.
Please try and google "Vectorized Code in JMP", all I get is this (https://community.jmp.com/t5/JMP-Blog/JSL-Tip-Use-Matrices-Instead-of-Lists/ba-p/29773). Please repeat the exercise for any of the other languages I have mentioned above and see how much wealth of information is made available to you. It is easy to write off my request, however I think it will serve our community and its users well if there is more documentation that goes deep into a couple of examples and addresses a few common problems.
Re: Using Match on a matrix without loopScripting Guide, Chapter 7 "Data Structures" Sections: Lists and Matrices have examples. Specifically, the Matrices subsections: "Subscripts" and "Indexing into a Matrix or List with Another Matrix or List". Also, Vince Faller's response to you about Lag functions on matrices contains several examples.
You should read the sections on lists, matrices and associative arrays.
Re: Using Match on a matrix without loopThanks Jeff. That worked.
Would request for documentation to be added on vectorizing operations with examples (request/ suggestion) as I search more and more for vectorization in JMP, I realise there are not sufficient blogs/documentation which helps guide users on the topic.
Re: Using Match on a matrix without loopRe: Using Match on a matrix without loopUse TestMat as the Subscript for A and assign it to TestMat1:
A = [0.1, 0.2, 0.3, 0.4];
TestMat = [1, 2, 3, 4, 4, 2, 3, 1, 3, 2, 4, 1];
TestMat1 = A[TestMat];
Show(TestMat1);
/*:
TestMat1 = [0.1, 0.2, 0.3, 0.4, 0.4, 0.2, 0.3, 0.1, 0.3, 0.2, 0.4, 0.1];