You can try both sides, I don't think anybody will be annoyed with this, but I'm not sure many people here use Wolfram... (the language, I mean)
I haven't played with this since a LONG time, and I can't test know...
Possible dumb suggestions from someone rusty. Can't you define f as Id_a (the identification function, something like
Code:
f[x_] := if[ x==a ; 1 ; 0 ]
evaluate the list (thus getting the coefficients for f[a] in each position), redefine f as Id_b, and so on?
Edit: looking at CoefficientArray documentation,
I'd say it should work, but f[a] most probably isn't seen as a variable (is your "a" a variable or an immediate value, like an integer?)... A variation could be to convert a, b, c, d into x, y, z, t. But that would suppose you have a good knowledge about the set, and its size is somehow limited.
This definitely seems like a good idea, so I'm going to try approach it from this angle and see if it works.
To talk about the edit, it's... complicated and quite long. My explanation above simplified what is actually happening, which is what makes this a bit trickier.
Basically, I'm working over Finite Fields, so all of the elements in the set are the elements in the Finite Field which aren't equal to 1 or 0, and the function F(a,b) is actually considerably longer.
When the number of elements in the field is prime, we have an easy description of all the elements (it's just {0,1,2,3,...,p-1} where p is the size of the field, since Fp = Z/pZ). We can write these as {a,0} (i.e. a+px=a+0x; since x-p=0).
When the number of elements in the Field is a power of a prime though, say p^n, it gets more complicated, because in this Case Fp^n is isomorphic Z[x] quotient by a polynomial satisfying certain conditions. Since it's quotiented by some polynomial, we get something like a+bx+xc^2 +...+zx^n and we can write it as {a,b,c,d,...,z,0}. It is not trivial to determine certain details in this situation. A simple example would be that in F9 = F3/<x^2+x+2> = 0,1,2,x,2x,1+x,1+2x,2+x,2+2x}, it's not easy to say what is {1,1}^(-1) = 1/(1+x)= (some element in the field, but we want to know what it is).
[To give an Example, in F9 we have {0,1,2,x,2x,1+x,1+2x,2+x,2+2x}. The inverse of (1+x), i.e. (1/(1+x)), is then (2+x) (since (1+x)*(2+x) = 2 + 3x + x^2 = 2 + 0 + (-1) = 2 + 2 = 4 = 1) but it's not 'obvious' that this is the case. In addition we can represent everything in the form a + bx where a and b are mod 3, so everything be represented as {a,b}]
For the moment, my code is only looking at the case where p is prime, so in truth, I could work with integers mod p and I think it should not, necessarily, be too tricky to implement.
However, I'm going to need to (after I get it working for primes) get it working for powers of primes too. Because of that, I'm trying to write the code as general as I can (using the finite field package) so it will end up 'easier' to apply it to fields of an arbitrary size. At the moment, every vector is simply {a,0}. After I make sure I can get it working for this case though, I'll need to set a function to make the vector size be sufficiently long, create a function that successfully enumerates all possible combinations in the vector so that I have a description of every element in the field, and then once I have that basically go through all of the combinations of elements in the field.
For this reason, I want to try and keep it as general as possible and avoid using specific values in any of the formulas, or any specific logical checks that depend on an actual value, since the value it's checking will also need to be written in terms of the finite field unless you're specifically defining it to be a real number .
I hope that may slightly clarify the actual context of the questions and may make it a little more clear what some of the challenges are in constructing any logical checks here.
EDIT: I should also clarify another approach that's possible here when dealing with Finite Fields is that because every Finite Field has at least one generator (Every element in Fq* can be written as a^b for some natural number b) we could, in theory, represent every element as the power of a generator. The issue here is that the problem of finding a generator is tough (very much so:
https://arxiv.org/pdf/1304.1206v4.pdf), and there are more than one, so we couldn't necessarily specific what the generator would be in any logical checks and it would have to be kept very general.
EDIT: Cpp, will do! I was hoping somebody here would be really familiar with Mathematica, or there's a really quick solution (such as the if Koren's suggestion works). If that suggestion isn't working I'll go to Stack Exchange then, thanks!