PLPGSQL store columns of a 2D query output into array variables

In some step of a plpgsql function I need to store a 2D query result into array variables.

The following code does the job for scalars (but fails with arrays):

SELECT col_a, col_b FROM my_table WHERE col_c = condition INTO var_a, var_b; 

The following does the job for ONE column and ONE array variable but not more than that:

SELECT ARRAY(     SELECT col_a     FROM my_table     WHERE col_c > condition ) INTO arr_a; 

How could I store multiple rows from col_a, b, c, d… Into their respective array variables without having to do a separate query for each column? Like in the first code example but for multiple rows and arrays.

Thanks for your time.

How to symbolically manipulate the closed form series output from the easyFourier package?

EasyFourier by @xzczd is a nice package to obtain a Fourier series in closed form, e.g.

f = x^2 easyFourierTrigSeries[f, {x, -\[Pi], \[Pi]}, \[Infinity]] 

enter image description here

However, the output cannot be manipulated symbolically, at least I don’t know how to. For instance, differentiating the Fourier series is not possible like this:

D[easyFourierTrigSeries[f, {x, -\[Pi], \[Pi]}, \[Infinity]],x] 

enter image description here

What I would like to do is something comparable to the following, where I have copied the summand manually into a regular Mathematica Sum:

enter image description here

BTW: How do I downscale the size of pictures in stack exchange? Is there no easier way to insert Mathematica output? How can I insert complicated Mathematica input code in 2d-mode? (Thanks for hints to these "meta" questions, too.)

Output a specific link in WordPress post if the single post’s category’s name contain certain word

I want to output a specific link in every post, depending on the post’s category. For example, If a post is in "travel" category, then the link to https://www.example.com/travelbooking will be displayed in this post. If a post is in "hotel" category, then the link to https://www.example.com/hotelbooking will be displayed in this post.

I tried this code

    <?php    $  category = get_the_category();   $  firstCategory = '$  category[0]->cat_name';   if (strpos($  firstCategory, 'travel') !== false) { echo '<a href="https://www.example.com/travelbooking">Visit travelbooking</a>'; }        if (strpos($  firstCategory, 'hotel') !== false)  {     echo '<a href="https://www.example.com/hotelbooking">Visit hotelbooking</a>';    }          else {      echo '<a href="https://www.example.com">Visit homepage</a>'; }       ?>  

But it doesn’t work, any suggestion?

Steam plotting of vector field showing empty output

I am trying to plot the stream lines for a vector field function, whose definition is exported to the wdx file uploaded here. The following simple code returns an empty plot:

ReadyFieldXY =  Import["C:\ReadyFieldXY.wdx"]; a0 = 0.00055; StreamPlot[Abs[ReadyFieldXY], {x, -a0/2, a0/2}, {y, -a0/2, a0/2}] 

enter image description here

I am not sure what is wrong here. Any suggestions would be appreciated.

Lists of labelled vectors, how to output a list of tuples which sum to zero

list = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 0, 1}, {1, 0,-1}, {-1, 0, -1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}};

list2 = {{2, 0, 0}, {0, 2, 0}, {0, 0, 2}, {-2, 0, 0}, {0, -2, 0}, {0, 0, -2}}

@Ulrich Neumann gave the following algorithm which finds the all zero sums (duplication is allowed) where "a" vectors are selected from list and "b" vectors from list2.

slist = Tuples[list, {a}]; listb = Tuples[list2, {b}] Table[{li, Select[slist, Total[#] == -Total[li] &]}, {li, listb}]

For instance, when a=2, and b=1, one part of the result which the above code gives:{{{2, 0, 0}}, {{{-1, 1, 0}, {-1, -1, 0}}, {{-1, -1, 0}, {-1, 1, 0}}, {{-1, 0, 1}, {-1, 0, -1}}, {{-1, 0, -1}, {-1, 0, 1}}}}

My problem is listing the results .I want to assign letters to each vectors in the list and list2, let list = {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12}; where a1={1, 1, 0}, a2={1, 0, 1}, a3={0, 1, 1}, a4={-1, 1, 0}, a5={1, -1, 0}, a6={-1, -1, 0},a7= {-1,0,1}, a8= {1,0,-1}, a9= {-1,0,-1}, a10={0,-1,1}, a11={0,1,-1}, a12={0,-1,-1},

and list2={b1, b2, b3, b4, b5, b6} where b1={2, 0, 0}, b2={0, 2, 0}, b3={0, 0, 2}, b4={-2, 0, 0}, b5={0, -2, 0}, b6={0, 0, -2}.

I want to have the results in the associated form. So for instance, reconsider the specific part of result: {{{2, 0, 0}}, {{{-1, 1, 0}, {-1, -1, 0}}, {{-1, -1, 0}, {-1, 1, 0}}, {{-1, 0, 1}, {-1, 0, -1}}, {{-1, 0, -1}, {-1, 0, 1}}}}. It needs to be in the form: {{b1}, {{a4, a6}, {a6, a4}, {a7, a9}, {a9, a7}}} and I want the whole output to be in terms of letters rather than explicit vectors. How can we manage this ?

Unity, connecting unlit shader output to compute shader?

I’m hoping to learn what my options are for sharing the outputs of simple unlit shaders with compute shaders that will operate on the data.

Is my only course of action to use a render texture with the unlit shader, and Graphics.Blit to render the shader to a texture2D that can be set on the Compute Shader? I was hoping something like a ComputeBuffer or GraphicsBuffer might be made accessible and writable in the unlit shader and then could just be used in the Compute shader also.

Problem with KarhunenLoeveExpansion’s output

I have a matrix called realizationMat, it contains 101 measurements of 90 realizations of a stochastic process.

I use KarhunenLoeveDecomposition over it as

VA1 = realizationMat[[1]]; VA2 = realizationMat[[2]]; VA3 = realizationMat[[3]]; KLVariablesB =    KarhunenLoeveDecomposition[{VA1, VA2, VA3, ...}]; 

Note that I have more elements VA, but I don’t write them for the shake of brevity.

In the documentation is written: rows of the transformation matrix m are the eigenvectors of the covariance matrix formed from the arrays ai. Also, The transformed arrays bi are uncorrelated, are given in order of decreasing variance, and have the same total variance as ai.

However, if I write ListPlot[{KLVariablesB[[2, 1]]}, Joined -> True], it doesn’t look like an eigenvector at all, see figure 1Figure 1, fist row of m. Also, if I instead plot ListPlot[{KLVariablesB[[1, 1]]}, Joined -> True], it looks way more as an eigenvector, see figure 2Figure 2, yet these aren’t the eigenvectors of the original covariance matrix.

Can someone please tell me what is wrong with my code?

Best regards.

How to change string output in hierarchy tree postgresql?

I have a table like this:

------------------------------------------------- |  id  | description         | parent_id   |  cost -------------------------------------------------- | 1    |  Radiology         |       NULL  | 0.00 | 2    |  Lab Tests         |       NULL  | 0.00 | 3    |  Normal Radiology  |         1   | 0.00 | 4    |  Resonance         |         1   | 100.00 | 1100 |  Cerebral Resonance|         4   | 200.00 | 1900 |  Blood Tests       |         2   | 10.00 | 2044 |  Calcium           |         2   | 50.00  --------------------------------------------------- 

I need to generate this kind of output:

Radiology    -->Normal Radiology    -->Resonance       -->Cerebral Resonance with contrast Lab Test     --> Blood Test     --> Calcium 

I’m working on Postgresql. I’ve been trying this with recursive CTE but I was unable to generate what I like:

WITH RECURSIVE hierarchy AS (     SELECT  id, CAST(description AS TEXT) AS parent_list     FROM    orders     WHERE   parent_id is null     UNION       SELECT  c.id,             CAST(c2.parent_list || ' --> ' || c.description as text) as parent_list     FROM orders c     INNER JOIN hierarchy c2 ON c.parent_id = c2.id )    SELECT  id, parent_list FROM    hierarchy GROUP BY id, parent_list ORDER BY parent_list; 

That recursive CTE produces the following non desirable output:

Radiology Radiology--> Normal Radiology Radiology--> Resonance Radiology--> Resonance --> Cerebral Resonance with contrast Lab Test Lab Test --> Blood Test Lab Test --> Calcium 

Can anyone please give a piece of advice?

How to select and delete all Output cells within current Selection only?

A similar question was already here: How to select and delete all Output cells?. But I have a more specific one: I want to delete all output cells within the currently selected cells only.

For this purpose I want to add an additional menu item Cell>Delete All Output within Selection.

Probably one would have to add something to

/usr/local/Wolfram/Mathematica/12.1/SystemFiles/FrontEnd/TextResources/X/MenuSetup.tr

Has anybody already made such an improvement and could he please post it here?

(The version in this case is 12.1 and it probably has to reflect the version in question. This path is for a Linux machine. On a Windows machine the paths begin at a different root but parts from Wolfram to TextRessources probably will look the same, except for the forward slashes being replaced by backward ones- /X/ might be special for Linux).