I am trying to manipulate some algebra with Maxima, here is my code :
Pd: matrix( [a00, a01, a02, a03], [a10, a11,a12,a13], [a20,a21,a22,a23]);
Pdd: matrix( [b00, b01, b02, b03], [b10, b11,b12,b13], [b20,b21,b22,b23]);
T1: col( Pd, 1) . transpose( col(Pdd,4) ) - col( Pd, 4 ) . transpose( col(Pdd,1) );
T2: col( Pd, 2) . transpose( col(Pdd,4) ) - col( Pd, 4 ) . transpose( col(Pdd,2) );
T3: col( Pd, 3) . transpose( col(Pdd,4) ) - col( Pd, 4 ) . transpose( col(Pdd,3) );
t: matrix( list_matrix_entries( T1 ), list_matrix_entries( T2 ), list_matrix_entries( T3 ) );
transpose( list_matrix_entries( t ) );
This finally gives 27 equations, something like :
matrix([a00*b03−a03*b00],
[a00*b13−a03*b10],
[a00*b23−a03*b20],
[a10*b03−a13*b00],
[a10*b13−a13*b10],
[a10*b23−a13*b20],
[a20*b03−a23*b00],
[a20*b13−a23*b10],
[a20*b23−a23*b20],
[a01*b03−a03*b01],
[a01*b13−a03*b11],
[a01*b23−a03*b21],
[a11*b03−a13*b01],
[a11*b13−a13*b11],
[a11*b23−a13*b21],
[a21*b03−a23*b01],
[a21*b13−a23*b11],
[a21*b23−a23*b21],
[a02*b03−a03*b02],
[a02*b13−a03*b12],
[a02*b23−a03*b22],
[a12*b03−a13*b02],
[a12*b13−a13*b12],
[a12*b23−a13*b22],
[a22*b03−a23*b02],
[a22*b13−a23*b12],
[a22*b23−a23*b22])
My question is, how is it possible to manipulate (rearrange) these 27 equations with Maxima into the form t=Ea, where a is all the a.. entries stacked as column vector.
Try this:
coefmatrix (list_matrix_entries (foo),
[a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23]);
where foo is the result of transpose( list_matrix_entries( t ) ); above.
Related
I'm trying to count longest and current streak from null or 1 values in google sheets.
It's going to be used in Data Studio, but I have to make calculation in Sheets.
I've tried a sultion from below post, but it's nor working for me and also I have null values not 0, and it has to stay this way (rows in sheet are being appended from google forms form, where I check whether I did a habit or not).
Google Sheets - How to count streaks of non-zero numbers on one column
Please help if you can, thanks before
Here is the spreadsheet with some example data
https://docs.google.com/spreadsheets/d/1GaaEJ24ERulPftYAILOuokY929HInkh-SjAJUEvrW5M/edit?usp=sharing
values to visualize in streaks
Use this to get the longest streak in data:
=arrayformula(
if(
len(join(""; Data!A1:A));
max( len( split(
concatenate( left(isblank(Data!A1:A)) );
"T"
) ) );
"no streak"
)
)
And this to get the last streak in the data:
=+sort(
if(
len(join(""; Data!A1:A));
len( transpose( split(
concatenate( left(isblank(Data!A1:A)) );
"T"
) ) );
"no streak"
);
sequence( rows(
transpose( split(
concatenate( left(isblank(Data!A1:A)) );
"T"
) )
) );
false
)
See your sample spreadsheet.
longest:
=INDEX(COLUMNS(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(IF(A1:A=""; 0; "×");;9^9)); " 0 "; )); " ")))
all:
=INDEX(QUERY(LEN(SUBSTITUTE(FLATTEN(TRIM(SPLIT(QUERY(
IF(A1:A=""; "×"; "¤");;9^9); "×"; ))); " "; ));
"where Col1 <> 0"))
last:
=INDEX(QUERY(SORT(LEN(SUBSTITUTE(FLATTEN(TRIM(SPLIT(QUERY(
IF(A1:A=""; "×"; "¤");;9^9); "×"; ))); " "; ));
SEQUENCE(ROWS(A1:A)-COUNTA(A1:A)); 0); "where Col1 <> 0 limit 1"; ))
I use this formula to get the data:
importXML("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[#class=('table')]//tr")
How to get price without a sign €/l?
Use substitute() or regexreplace() with iferror(), like this:
=arrayformula(
iferror(
iferror(
0.001 *
value(
substitute(
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[#class=('table')]//tr"),
" €/l", ""
)
),
0.001 *
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[#class=('table')]//tr")
),
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[#class=('table')]//tr")
)
)
Or, depending on your locale, it may be:
=arrayformula(
iferror(
iferror(
0,001 *
value(
substitute(
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[#class=('table')]//tr");
" €/l"; ""
)
);
0,001 *
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[#class=('table')]//tr")
);
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[#class=('table')]//tr")
)
)
The 0.001 * bit and the outer iferror() are only required when your spreadsheet locale uses period as decimal mark.
use:
=QUERY({IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[#class=('table')]//tr")\ INDEX(SUBSTITUTE(IMPORTXML(
"https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[#class=('table')]//tr"); " €/l"; "");;2)};
"select Col1,Col4,Col3")
update:
=ARRAYFORMULA(IFNA(TEXT(REGEXEXTRACT(SUBSTITUTE(
IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[#class=('table')]//tr"); "."; ",");
"\d+,\d+")*GOOGLEFINANCE("currency:EURUSD"); "0.00"); TRIM(
IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[#class=('table')]//tr"))))
Trying to combine range E4:I into J4:J with the Array Formula of:
=ArrayFormula( regexreplace( regexreplace( transpose( trim( query( transpose( regexreplace( trim( E4:I ) , " " , "~" ) ) ,, 9^99 ) ) ) , " " , ", " ) , "~" , " " ) )
This formula works well but I want to exclude duplicates in each row.
Here is a link to the sheet. Link
You can try this modified formula from a similar post:
=INDEX(
REGEXREPLACE(SORT(
SPLIT(
TRANSPOSE(QUERY(
QUERY(
UNIQUE(
SPLIT(
FLATTEN(
ROW(E2:I11) & "♦♥" & E2:I11
), "♥"
) & ", "
),
"SELECT MAX(Col2)
WHERE Col2 IS NOT NULL
GROUP BY Col2
PIVOT Col1",
),,99
)),"♦"
), 1, TRUE),
"^(?:,\s*)+|(?:,\s*)+$|(,\s)\s*(?:,\s*)*",
"$1"
),,2)
Output:
Note:
Output is automatically sorted alphabetically
You can change E2:I11 to E2:I but it will be slower than limiting your range. If you have a column that can identify until what row is populated, add an IF statement and limit your formula to only process those rows.
Reference:
https://stackoverflow.com/a/67837006/17842569
I have a list of reservations with a startDate, endDate and itemNumber. Now i want to have a list of all the dates between those dates and the itemnumber next to it. I have this working for 1 reservation, but i can't get it to work with multiple reservations in one arrayformula.
I have a sample sheet (edit rights) with my formula's and the expected outcome.
Someone here that can help me out?
Sample sheet
Two Formula Version:
Item Column (Assuming K):
=ArrayFormula(TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),",")))
or
=ArrayFormula(
IFNA(
HLOOKUP(
"StartDate",
Reservation!B:B,
MATCH(
FILTER(K3:K,K3:K>0),
Reservation!D2:D,
0
)+1,
0
)+IFNA(
ROW(K3:K)-2-MATCH(K3:K,K3:K,0)
)
)
)
This generates the list of Items based on the difference between the dates.
Date Column (Assuming J):
=ArrayFormula(IFNA(HLOOKUP("StartDate",Reservation!B:B,MATCH(FILTER(K3:K,K3:K>0),Reservation!D2:D,0)+1,0)+IFNA(ROW(K3:K)-2-MATCH(K3:K,K3:K,0))))
or
=ArrayFormula(
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
)
)
Based on the Item, get its offset in the Item column (above) and add it to the Start Date for the corresponding item.
Single Formula Version:
Looks very messy, but is mostly just substituting K's into second formula above.
=ArrayFormula(
{
IFNA(HLOOKUP("StartDate",Reservation!B:B,MATCH(TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),",")),Reservation!D2:D,0)+1,0)+IFNA(SEQUENCE(COUNTA(TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),","))))-MATCH(TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),",")),TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),",")),0))),
TRANSPOSE(SPLIT(JOIN(,REPT(Reservation!D2:D&",",1+Reservation!C2:C-Reservation!B2:B)),","))
})
Or if you prefer:
=ArrayFormula(
{
IFNA(
HLOOKUP(
"StartDate",
Reservation!B:B,
MATCH(
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
),
Reservation!D2:D,0
)+1,
0
)+IFNA(
SEQUENCE(
COUNTA(
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
)
)
)-MATCH(
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
),
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
),
0
)
)
),
TRANSPOSE(
SPLIT(
JOIN(,
REPT(
Reservation!D2:D&",",
1+Reservation!C2:C-Reservation!B2:B
)
),
","
)
)
})
I'm wondering if anyone could give me a helping hand in shuffling a comma-separated list of values in one cell in Google sheets. My data looks like this:
peter, andrew, mike, michael, ..., thomas
I'd like to randomly shuffle this string for each row and I have about a thousand rows that all have one cell that looks like this.
Any formula or link to a page where I can get closer to a solution would be greatly appreciated.
Draggable Single Formula
Here's a formula if you're ok with dragging a formula down:
=ArrayFormula(
JOIN(
", ",
Array_Constrain(
SORT(
TRANSPOSE(
{
SPLIT(A1, ", ");
RANDARRAY(1,COUNTA(SPLIT(A1, ", ")))
}),
2,
),
COUNTA(SPLIT(A1,", "))
,1
)
)
)
Two ArrayFormulas
It may be possible to combine these two into one, so I may revisit this later.
Make sure you have three columns clear. I chose C as my start column.
=ArrayFormula(
SORT(
{
ARRAY_CONSTRAIN(
SPLIT(
TRANSPOSE(
SPLIT(
TEXTJOIN(
",",
1,
(SEQUENCE(COUNTA(A:A))-1)&"|"&SPLIT(FILTER(A:A&", ",LEN(A:A)),", ")
),
","
)
),
"|"
),
COUNTA(
SPLIT(TEXTJOIN(", ",1,A:A),", ")
),
2
),
RANDARRAY(
COUNTA(
SPLIT(
TEXTJOIN(", ",1,A:A),
", "
)
),
1
)
},1,1,3,1)
)
Final result.
=ArrayFormula(
TRANSPOSE(
SPLIT(
REGEXREPLACE(
TEXTJOIN(
", ",
,
UNIQUE(
TRANSPOSE(
IF(
TRANSPOSE(FILTER(C:C,LEN(C:C)))=FILTER(C:C,LEN(C:C)),
FILTER(D:D,LEN(D:D)),
";"
)
)
)
),
", (;, )+",
";"
),
";"
)
)
)
The tricky part was getting the "group concatenation" to work.