11,379 reputation
12456
bio website
location
age 28
visits member for 2 years, 7 months
seen yesterday

Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I'm using my "patterns for patterns" in things such as Cases, however I wouldn't call that transformations using the patterns. The question is really just about using pattern matching to match things that are themselves patterns.
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard in the 3'rd codebox. I write MatchQ[b, (a /. {HoldPattern -> hp_,...} /. {f -> f_,...}) /; And[hp === HoldPattern,...]] Now the "f-> f_" replaces the literal f with a pattern. The method goes, 1: break down all patterns, 2: inject new patterns; 3: Verify that all the structure of the broken down patterns is still correct.
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I substitute the literals for patterns after "breaking apart" other patterns by switching out the heads Pattern, Blank and such.
Jan
16
revised Pattern matching a pattern with patterns
deleted 49 characters in body
Jan
16
comment Pattern matching a pattern with patterns
@LeonidShifrin My clearification has nothing to do with types, I just chose those, since they are the type of structure you will typically see in a Pattern. I'm editing to remove the unwanted connection.
Jan
16
comment Pattern matching a pattern with patterns
I have a problem with the serialization. It'll give the same for eg. a[b,c] and a[b@c], so your solution gives true when testing with a = HoldPattern[g[x_@y_, _, {1, 2}, q : {g_, h_}]] :> g[x] + h[y] and the same b.
Jan
16
revised Pattern matching a pattern with patterns
added 852 characters in body
Jan
16
comment Pattern matching a pattern with patterns
@Mr.Wizard I don't follow you, f and g are never considered the same. When matching the pattern f->f_ replaces the symbol f with a pattern that (maybe confusingly so) is called f. You could equally well write f->x_ and then have x match f and g in each respectively.
Jan
16
comment Pattern matching a pattern with patterns
It might be cleaner, but it won't work in general for searching through patterns, only those that happen to take the form of DelayedRules, unless I'm misunderstanding something? Also, how would you go about extracting elements using your method(see edit)?
Jan
16
revised Pattern matching a pattern with patterns
added 322 characters in body
Jan
16
comment Pattern matching a pattern with patterns
I'm not sure why you feel the need to explicitly split up into lhs/rhs. Why not just match the entire patterns?
Jan
16
answered Trig angles simplifying in worksheet
Jan
16
asked Pattern matching a pattern with patterns
Jan
15
comment Compiling LinearSolve[] or creating a compilable procedural version of it
@Jagra What I was asking was how it changes. You posted a constant matrix and a constant array. They per definition never change. If you could for instance provide a matrix on the form {{a,b},{0,4}} and say with a and b having different values. That would be a useful description. Just saying "the values within the matrix and vector change constantly" is not useful, how do they change, do they all change?, which ones change etc. This is the information needed in order to judge whether you just need a single solution or a complete framework like LAPACK.
Jan
15
comment Compiling LinearSolve[] or creating a compilable procedural version of it
@Jagra But you never change any elements of it? Then it's trivial to just solve it, since you don't even need to check that pivots are non-zero.
Jan
15
awarded  Nice Answer
Jan
15
answered Compiling LinearSolve[] or creating a compilable procedural version of it
Jan
15
comment Compiling LinearSolve[] or creating a compilable procedural version of it
@Jagra could you provide an update about what the general shape of your matrices is?
Jan
15
comment Compiling LinearSolve[] or creating a compilable procedural version of it
@Jagra You shouldn't be concerned with the return value. The question is what your input matrix looks like, for instance if it was {{a,b},{0,d} with rhs {r1,r2} where you know that a and d are non-zero, then you can call it once to see that your solution will always be: {(d r1 - b r2)/(a d), r2/d}. Now this method of cause will not work if you have an arbitrary matrix, but it you have a pattern and only some inputs, you can just solve once and compile the resulting definition.
Jan
14
answered Is there a concise form of Which or similar conditional?