Currently, writing a *.spec file for an RPM. How can I dynamically define variables so that they utilize the parameterized macro?
Per the rpm documentation I've come up with following:
1 %define postgresql_macro() (?%1?%2?%3?%4?%5)
2 %define postgresql_ver %postgresql_macro 9 . 4 . 15
3 %define postgresql_ver_short %postgresql_macro 9 . 4 .
4 %define postgresql_ver_major 9 4
Line 1 is the macro that accepts parameters.
Line 2 should define postgresql_ver as 9.4.15.
LIne 3 should define postgresql_ver_short as 9.4.
Line 4 should define postgresql_ver_major as 94.
How can I test this? Is this correct?
First, you have it wrong. it should be:
%define postgresql_macro() %1%2%3%4%5
%define postgresql_ver %postgresql_macro 9 . 4 . 15
%define postgresql_ver_short %postgresql_macro 9 . 4 .
%define postgresql_ver_major 9 4
You can test this way. Put in your SPEC file:
%prep
%define postgresql_macro() %1%2%3%4%5
%define postgresql_ver %postgresql_macro 9 . 4 . 15
%define postgresql_ver_short %postgresql_macro 9 . 4 .
%define postgresql_ver_major 9 4
echo %{postgresql_ver}
And now run rpmbuild -bp your.spec. This should print: 9.4.15
Related
I have a Big CSV file (~2GB) that contains a parameter X that for each day has around 1000 record.
What I want to do is transform this column to a set features (vectors) of length 1000 (one for each day).
For example:
==> Day 1 Day P1
1 1
1 2
1 5
1 9
1 .
1 .
1 .
1 6
==> Day 2 1 4
2 1
2 2
2 5
2 7
2 .
2 .
2 .
2 8
Will be transformed to:
d1 1 2 5 9 . . . 6
d2 4 1 2 5 . . . 8
.
.
.
dn
How can I do that in Scala ?
I know that there will be issue with the memory, I'll try to store the result on multiple steps.
Here is what I've tried so far:
df_data.map(x => (x(1),x(3))).filter(x=> x._1== 1).zipWithIndex.map(x=> (x._1._1,(x._2,x._1._2))).groupByKey()
Now I get something like:
(1, (0,val1),(1,val2),(2,val3),...,(n,valn))
I have two lines where ii should increment 1:12
1 2 3 4 5 6 7 8 9 10 11 12
for ii=1:6
ii %line1
ii+1 %line2
end
Instead I get ii
1 2 2 3 3 4 4 5 5 6 6 7
Ps: I need to use two lines in the for loop due to functions being called from these lines and filenames are created based on ii variable
If you really need two lines, try:
for ii=1:6
ii*2-1
ii*2
end
I have created a ternary tree in matlab as below.
for i=1:4
a(i, j:j+2) = 1;
a(j:j+2, i) = 1;
j=j+3;
end
This code works fine and the numbering of the tree is in pre-order starting with Root Node as 1 and then the nodes are numbered as
1
---------------------------------------------------
2 3 4
---------------------------------------------------------
5 6 7 8 9 10 11 12 13
My question is how to write code that will get the paths
1 2 5, 1 2 6, 1 2 7 and similarly for the rest and save these paths to a file. I am doing some trial and error codes now.
Given a number N, I would like to create a matrix of x columns with every combination of a subset of N. For example, if N is 16 and x is 3 then I should get a matrix of 560 rows and each row will have 3 columns and contain a unique combination from the numbers 1 to 16.
Can I use a function zzz(N,x) ?
I will be generating a lot of them with different N and x values so a for loop will slow things down.
Just use the nchoosek function:
N = 16;
x = 3;
nchoosek(1:N, x)
returns 560 rows like this:
. . .
. . .
. . .
1 2 13
1 2 14
1 2 15
1 2 16
1 3 4
1 3 5
1 3 6
1 3 7
. . .
. . .
. . .
I'm trying to start the circshift at the specific index of a number using the find command how can I do this? See example code below
%test find and circshift
a=[3:2:11]
%find index of number and start there
a_ind=find(a==9)
b=circshift(a,[0 a_ind])
I get a =[3 5 7 9 11]
a_ind = 4
b = [ 5 7 9 11 3]
I'm trying to get the circshift (b) to start at 9 and have
b = [9 11 3 5 7]
Please note a_ind will vary so I just can't have circshift starting at 2 each time
Here's another option that's good for vectors:
a=[3:2:11];
shift = find(a==9);
circshift(a(:), -shift + 1)'
a(:) guarantees you a column vector and circshift shifts on the row dimension i.e. it needs a column vector. Then just transpose again at the end to recover your row vector. You want to shift left so you must specify a negative shift.
I think you want
>> circshift(a,[0 (length(a)-a_ind+1)])
ans =
9 11 3 5 7
If I try with a different vector a:
>> a=[3:1:11]
a =
3 4 5 6 7 8 9 10 11
>> a_ind=find(a==9)
a_ind = 7
>> circshift(a,[0 (length(a)-a_ind+1)])
ans =
9 10 11 3 4 5 6 7 8