I have one table from this type:
Equipment TimestampEqmt
truck1 timetruck1
truck2 timetruck2
truck3 timetruck3
truck1 timetruck4
truck2 timetruck5
truck3 timetruck6
and another with GPS coordinates for the trucks
Equipment TimestamGPS X Y Z
truck1 TimestamGPS1 X1 Y1 Z1
truck2 TimestamGPS2 X2 Y2 Z2
truck3 TimestamGPS3 X3 Y3 Z3
truck1 TimestamGPS4 X4 Y4 Z4
truck2 TimestamGPS5 X5 Y5 Z5
truck3 TimestamGPS6 X6 Y6 Z6
truck1 TimestamGPS1 X7 Y7 Z7
truck2 TimestamGPS2 X8 Y8 Z8
truck3 TimestamGPS3 X9 Y9 Z9
truck1 TimestamGPS1 X10 Y10 Z10
truck2 TimestamGPS2 X11 Y11 Z11
truck3 TimestamGPS3 X12 Y12 Z12
How to get for every TimestampEqmt and Equipment from first table, first GPS coordinates where TimestamGPS < TimestampEqmt?
The result should be like this:
Equipment TimestampEqmt TimestamGPS X Y Z
truck1 timetruck1 TimestamGPS7 X7 Y7 Z7
truck2 timetruck2 TimestamGPS11 X11 Y11 Z11
truck3 timetruck3 TimestamGPS12 X12 Y12 Z12
Which means that TimestamGPS7 is the first smaller timestamp depending on timetruck1 for truck1.
Related
I have a row array as shown below:
X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4 ..... Xn Yn Zn
This row array always starts with the value of X and with the value of Z. I want to rearrange them as a multidimensional array:
X1 X2 X3 X4 X5 .... Xn
Y1 Y2 Y3 Y4 Y5 .... Yn
Z1 Z2 Z3 Z4 Z5 .... Zn
The size of the original array varies in each case. Any help to how to approach this problem would be helpful.
Use reshape function setting second dimension as []
reshaped_array = reshape(myarray,3,[]);
I was looking for a solution (avoiding vba) to reorganize 3 columns representing data1, data2, and f(data1,data2) into a 2d array.
The data is as follows:
X1 X2 Z_1_2
X1 X3 Z_1_3
X1 X4 Z_1_4
X1 X5 Z_1_5
X2 X3 Z_2_3
X2 X4 Z_2_4
X2 X5 Z_2_5
X3 X4 Z_3_4
X3 X5 Z_3_5
X4 X5 Z_4_5
Edit: I will give some more details...
X are strings and Z are numerics.
The results should be as following:
X1 X2 X3 X4 X5
X1 1 Z_1_2 Z_1_3 Z_1_4 Z_1_5
X2 Z_1_2 1 Z_2_3 Z_2_4 Z_2_5
X3 Z_1_3 Z_2_3 1 Z_3_4 Z_3_5
X4 Z_1_4 Z_2_4 Z_3_4 1 Z_4_5
X5 Z_1_5 Z_2_5 Z_3_5 Z_4_5 1
Thanks !!!
So you need to set up the headers, correctly both the row and column headers.
Then if the Upper left cell put this formula:
=IFERROR(INDEX($C:$C,MATCH($G2&"|"&H$1,$A:$A&"|"&$B:$B,0)),IFERROR(INDEX($C:$C,MATCH(H$1&"|"&$G2,$A:$A&"|"&$B:$B,0)),1))
This is an array formula and needs to be confirmed with Ctrl-Shift-Enter instead of just enter. Copy and fill the rest of the array.
One warning this will take time to compute, It can be sped up by limting the full column references to only those with data; $C:$C in this instance would be $C$1:$C$10.
something like that?
=IF(F$1=$E2,1,INDEX($C$1:$C$10,IFERROR(MATCH(F$1&"_"&$E2,$A$1:$A$10&"_"&$B$1:$B$10,),MATCH($E2&"_"&F$1,$A$1:$A$10&"_"&$B$1:$B$10,))))
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
if you get worried by the & you can avoid it like this:
=IF(F$1=$E2,1,INDEX($C$1:$C$10,MAX(ROW($1:$10)*((F$1=$A$1:$A$10)*($E2=$B$1:$B$10)+($E2=$A$1:$A$10)*(F$1=$B$1:$B$10)))))
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
I have a file which contains:
x1 x2 x3 x4
x5 x6 x7 x8
x9
Which I want:
x1
x2
x3
.
.
How you do that using awk or in another ways?
With awk:
$ awk '1' RS=' ' ORS='\n' file
x1
x2
x3
x4
x5
x6
x7
x8
x9
However personally I would do:
$ xargs -n1 < file
x1
x2
x3
x4
x5
x6
x7
x8
x9
or:
$ grep -o '\S*' file
x1
x2
x3
x4
x5
x6
x7
x8
x9
I got a problem while reading my input. I am getting input with fgetc(stdin). Before the equations I get number of equations. My code looks like this
char c;
for (int i = 0; i < rows; i++)
{
do
{
c=fgetc(stdin);
if(c!='+' && c!='-' && c!='\n' && !isspace(c) && c!='=' && c!=EOF)
{
l++;
equation[l]=c;
}
if(/* other conditions*/) eqToGauss(i,l,s,gaussMatrix,equation,sign);
} while (c!= '\n');
}
Problem is that, at the end of the penultimate lane(lane 8, after number 584), it gets '\n' and after that it won't stop the program but acts like it is running in loop. Xcode debug goes into assembler mode and the next character it reads since that moment is '\xff'. That algorithm works fine with short/ less equations.
This input is without empty lines after equations.
299 x2 + 529 x3 + 194 x5 + 282 x3 + 364 x5 + 135 x4 + 388 x1 + 492 x2 + 236 x4 + 165 x2 + 557 x1 = 135 x3 + 26 x2 + 566
482 x2 + 582 x5 = 530 x3 + 417 x1 + 424 x3 + 147 x5 + 81 x4 + 143 x3 + 195 x4 + 8 x2 + 479
532 x5 + 61 x4 + 318 x4 + 288 x5 + 573 x5 + 162 x4 = 99 x4 + 44 x3 + 190 x1 + 60
224 x1 + 145 x4 + 29 x4 + 1 x1 + 549 x5 + 186 x5 + 509 x4 + 178 x4 + 321 x1 + 320 x1 = 172 x4 + 537 x5 + 15
398 x5 + 79 x5 + 357 x2 + 153 x5 + 37 x5 + 301 x1 + 174 x5 + 111 x2 = 170 x4 + 208 x1 + 368 x3 + 14 x4 + 100 x2 + 531 x2 + 578 x3 + 510 x4 + 583 x1 + 281
301 x5 + 394 x5 + 272 x3 + 514 x5 = 412 x2 + 288 x4 + 182 x5 + 218 x1 + 210
331 x5 + 333 x4 + 376 x2 + 490 x5 + 275 x5 + 105 x4 + 498 x2 + 152 x3 + 51 x2 = 328 x4 + 135 x5 + 452 x4 + 62 x5 + 533 x1 + 261 x3 + 527 x1 + 124 x5 + 295 x4 + 532 x2 + 4
388 x2 + 415 x4 + 172 x4 + 403 x5 + 30 x1 = 511 x3 + 231 x5 + 104 x2 + 516 x2 + 380 x2 + 274 x5 + 522 x2 + 584
554 x1 + 434 x4 + 288 x5 + 98 x2 + 85 x5 + 413 x2 + 40 x1 = 584 x3 + 113 x2 + 262 x5 + 348 x5 + 285 x5 + 328 x4 + 351 x4 + 77 x5 + 149 x5 + 170 x1 + 203
You read the EOF(end-of-file) character with fgetc and can't exit the loop as the exit statement is c != '\n', but as long the EOF is in the stream the fgetc won't consume it and won't change variable c, thus causing infinite loop.
You need to test for EOF on fgetc() -- the 0xFF implies end of file, but I don't see anything in your code fragment that stops reading input on EOF.
if( (c = fgetc(stdin)) == EOF )
{
printf( "end of input\n" );
exit( 0 );
}
This is the prototype for the function:
v4si __builtin_ia32_shufps (v4si, v4si, int)
On some websites I found they had but hex in the int field, and it looked liked it separated high and low bits, but what I want is a logical 32 bit shift.
X3 X2 X1 X0 shifted by 32 bits to get X2 X1 X0 0
Another example using 2 v4si vectors:
X7 X6 X5 X4 | X3 X2 X1 X0, where each X is a 32 bit and what I want for a shift is the
same a logical shift, but with each vector element. So:
X7 X6 X5 X4 | X3 X2 X1 X0 << 2 = X5 X4 X3 X2 | X1 X0 0 0
Is shufps the right command to do this?
Looking at your example with two vectors I think what you're probably looking for is _mm_alignr_epi8 (PALIGNR). This works for any shift of a pair of vectors by an arbitrary number of bytes, so you would need to multiply the shift parameter by sizeof(int), e.g.
v = _mm_alignr_epi8(v0, v1, 2 * sizeof(int));
Note that this instruction is only available in SSSE3 and later, which means pretty much any Intel CPU since ~ 2005.