matrix - How can I save multi variable results in a data structure using Pari? -


i have function loops on input , produces 0 or more results, each result consisting of 3 numbers. want keep results in data structure (e.g., matrix or vector of vectors) don't know how many entries there until loop terminates. need able extract column of results (e.g.the first variable of each entry) easily.

first off, please @ pari/gp reference vectors/matrices stuff: https://pari.math.u-bordeaux.fr/dochtml/html-stable/vectors__matrices__linear_algebra_and_sets.html.

you can use matrix in loop follows:

entries = mat();  for(i = 1, 1000, {     your_entry = [i, i+1, i+2];     entries = matconcat([entries; mat(your_entry)]); });  print(matsize(entries)) gp> [1000, 3]  print(entries[,1])  \\ fetch 1st column 

hope, helps.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -