6 added 427 characters in body

You are doing something unusual here. Taking a diagonal form and insisting on the variables being nonnegative is possible but is not really natural. One counts a representation with some $x$ as distinct from the same representation with $-x.$

However, this is what you did. I can fill in the beginning of the story, enough for those expert in quadratic fields to finish it. First, for all odd numbers $n,$ the number of primitive representations with $\pm$ being considered distinct is $h(-32n),$ being the class number of positive binary quadratic forms of the same discriminant has $f(x,y) = x^2 + 8ny^2.$

Now, there is typically no reason for the number of representations, or number of primitive representations, by a diagonal ternary form $a x^2 + b y^2 + c z^2$ to be divisible by 8. However, once we restrict $n \equiv 7 \pmod 8,$ we immediately find that $x,y,z$ are odd. Odd means nonzero. Furthermore, $1,2,4$ are distinct. So there is no permutation of a given $x,y,z$ that gives the same value. As a result, each triple has exactly eight full versions with the possible $\pm$ on each of three positions.

So far, with your positive variables, the number of primitive representations is $$h(-32n)/8.$$

Alright, you wanted primes. So primitive representations agree with representations. The other effect is that the number of genera of (positive binary forms of) discriminant $-32p$ is four.

Finally we get to distinguish $7 \pmod {16}$ and $15 \pmod {16}.$ When $p \equiv 15 \pmod {16},$ the number of classes in the principal genus is divisible by 4, because the number of fourth powers in the class group is even. For a given $p \equiv 15 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ and $\langle 8,8, p+2 \rangle$ and add up to an even number of classes, should there be any others. For a given $p \equiv 7 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ (but not the other one, it is a square but not a fourth power) and add up to an odd number of classes, should there be any others. Put those together, the principal genus has either a multiple of four classes or twice an odd number, multiply by four genera and you get either a multiple of sixteen or $8 \pmod {16},$ finally divide by 8 and you get either an even number or an odd number.

Probably enough. Relating primitive representations by ternaries (of numbers relatively prime to the discriminant) to a class number goes back to Gauss and the Disquisitiones. As David pointed out, Joel had actually required that $x,y,z$ be odd, so primes $1,3,5 \pmod 8$ are simply not represented in the requested manner. If we remove the oddness restriction, we still get $h(-32p),$ and $x$ must still be odd, but either $y$ or $z$ will be $0$ in some representations, meaning we lose the strict eight to one ratio of representations to nonnegative representations.

Bonus paragraph: the group of fourth powers is a subgroup of the principal genus, for positive binary forms. Sometimes it coincides with the squares, sometimes it is smaller. Here it is a subgroup of index two. The reason for my interest is an article of Estes and Pall, in which they show that the spinor kernel is precisely the fourth powers, two binary forms of the same discriminant are in the same genus if their ratio is a square, and in the same spinor genus if their ratio is a fourth power in the class group. If we take the principal form $x^2 + ny^2,$ then a form in the principal genus that is not a fourth power, then add some $k n^2 z^2,$ if there are no 2-adic problems the resulting ternary forms are in the same genus but distinct spinor genera. So this is a source of interesting examples.

NOTE: by a few trivial lines, the condition I am referring to as "a fourth power in the class group" is the same as "the square of a form that is in a genus containing an ambiguous form." For our discriminant, the two ambiguous forms mentioned occur in the principal genus, and two others, $\langle 4,4, 2p +1 \rangle$ and $\langle 8,0, p \rangle$ are together in a second genus. There are two genera without ambiguous forms. This is from Dennis Estes and Gordon Pall, Spinor Genera of Binary Quadratic Forms, Journal of Number Theory, vol. 5 (1973), pages 421-432.

Furthermore, it should be noted that the four genera are separated quite easily by the odd values they represent modulo 8. It's traditional. The principal genus represents only $1 \pmod 8,$ as in the displayed values $1,p+2.$ The other genus containing ambiguous forms represents only $7 \pmod 8,$ as in $p, 2p+1.$ One of the genera without ambiguous forms represents only $3 \pmod 8,$ the other only $5 \pmod 8.$ So there.

5 added 572 characters in body

You are doing something unusual here. Taking a diagonal form and insisting on the variables being nonnegative is possible but is not really natural. One counts a representation with some $x$ as distinct from the same representation with $-x.$

However, this is what you did. I can fill in the beginning of the story, enough for those expert in quadratic fields to finish it. First, for all odd numbers $n,$ the number of primitive representations with $\pm$ being considered distinct is $h(-32n),$ being the class number of positive binary quadratic forms of the same discriminant has $f(x,y) = x^2 + 8ny^2.$

Now, there is typically no reason for the number of representations, or number of primitive representations, by a diagonal ternary form $a x^2 + b y^2 + c z^2$ to be divisible by 8. However, once we restrict $n \equiv 7 \pmod 8,$ we immediately find that $x,y,z$ are odd. Odd means nonzero. Furthermore, $1,2,4$ are distinct. So there is no permutation of a given $x,y,z$ that gives the same value. As a result, each triple has exactly eight full versions with the possible $\pm$ on each of three positions.

So far, with your positive variables, the number of primitive representations is $$h(-32n)/8.$$

Alright, you wanted primes. So primitive representations agree with representations. The other effect is that the number of genera of (positive binary forms of) discriminant $-32p$ is four.

Finally we get to distinguish $7 \pmod {16}$ and $15 \pmod {16}.$ When $p \equiv 15 \pmod {16},$ the number of classes in the principal genus is divisible by 4, because the number of fourth powers in the class group is even. For a given $p \equiv 15 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ and $\langle 8,8, p+2 \rangle$ and add up to an even number of classes, should there be any others. For a given $p \equiv 7 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ (but not the other one, it is a square but not a fourth power) and add up to an odd number of classes, should there be any others. Put those together, the principal genus has either a multiple of four classes or twice an odd number, multiply by four genera and you get either a multiple of sixteen or $8 \pmod {16},$ finally divide by 8 and you get either an even number or an odd number.

Probably enough. Relating primitive representations by ternaries (of numbers relatively prime to the discriminant) to a class number goes back to Gauss and the Disquisitiones. As David pointed out, Joel had actually required that $x,y,z$ be odd, so primes $1,3,5 \pmod 8$ are simply not represented in the requested manner. If we remove the oddness restriction, we still get $h(-32p),$ and $x$ must still be odd, but either $y$ or $z$ will be $0$ in some representations, meaning we lose the strict eight to one ratio of representations to nonnegative representations.

Bonus paragraph: the group of fourth powers is a subgroup of the principal genus, for positive binary forms. Sometimes it coincides with the squares, sometimes it is smaller. Here it is a subgroup of index two. The reason for my interest is an article of Estes and Pall, in which they show that the spinor kernel is precisely the fourth powers, two binary forms of the same discriminant are in the same genus if their ratio is a square, and in the same spinor genus if their ratio is a fourth power in the class group. If we take the principal form $x^2 + ny^2,$ then a form in the principal genus that is not a fourth power, then add some $k n^2 z^2,$ if there are no 2-adic problems the resulting ternary forms are in the same genus but distinct spinor genera. So this is a source of interesting examples.

NOTE: by a few trivial lines, the condition I am referring to as "a fourth power in the class group" is the same as "the square of a form that is in a genus containing an ambiguous form." For our discriminant, the two ambiguous forms mentioned occur in the principal genus, and two others, $\langle 4,4, 2p +1 \rangle$ and $\langle 8,0, p \rangle$ are together in a second genus. There are two genera without ambiguous forms. This is from Dennis Estes and Gordon Pall, Spinor Genera of Binary Quadratic Forms, Journal of Number Theory, vol. 5 (1973), pages 421-432.

4 added 10 characters in body

You are doing something unusual here. Taking a diagonal form and insisting on the variables being nonnegative is possible but is not really natural. One counts a representation with some $x$ as distinct from the same representation with $-x.$

However, this is what you did. I can fill in the beginning of the story, enough for those expert in quadratic fields to finish it. First, for all odd numbers $n,$ the number of primitive representations with $\pm$ being considered distinct is $h(-32n),$ being the class number of positive binary quadratic forms of the same discriminant has $f(x,y) = x^2 + 8ny^2.$

Now, there is typically no reason for the number of representations, or number of primitive representations, by a diagonal ternary form $a x^2 + b y^2 + c z^2$ to be divisible by 8. However, once we restrict $n \equiv 7 \pmod 8,$ we immediately find that $x,y,z$ are odd. Odd means nonzero. Furthermore, $1,2,4$ are distinct. So there is no permutation of a given $x,y,z$ that gives the same value. As a result, each triple has exactly eight full versions with the possible $\pm$ on each of three positions.

So far, with your positive variables, the number of primitive representations is $$h(-32n)/8.$$

Alright, you wanted primes. So primitive representations agree with representations. The other effect is that the number of genera of (positive binary forms of) discriminant $-32p$ is four.

Finally we get to distinguish $7 \pmod {16}$ and $15 \pmod {16}.$ When $p \equiv 15 \pmod {16},$ the number of classes in the principal genus is divisible by 4, because the number of fourth powers in the class group is even. For a given $p \equiv 15 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ and $\langle 8,8, p+2 \rangle$ and add up to an even number of classes, should there be any others. For a given $p \equiv 7 \pmod {16},$ the fourth powers include $\langle 1,0, 8p \rangle$ (but not the other one, it is a square but not a fourth power) and add up to an odd number of classes, should there be any others. Put those together, the principal genus has either a multiple of four classes or twice an odd number, multiply by four genera and you get either a multiple of sixteen or $8 \pmod {16},$ finally divide by 8 and you get either an even number or an odd number.

Probably enough. Relating primitive representations by ternaries (of numbers relatively prime to the discriminant) to a class number goes back to Gauss and the Disquisitiones. As David pointed out, Joel had actually required that $x,y,z$ be odd, so primes $1,3,5 \pmod 8$ are simply not represented in the requested manner. If we remove the oddness restriction, we still get $h(-32p),$ and $x$ must still be odd, but either $y$ or $z$ will be $0$ in some representations, meaning we lose the strict eight to one ratio of representations to nonnegative representations.

Bonus paragraph: the group of fourth powers is a subgroup of the principal genus, for positive binary forms. Sometimes it coincides with the squares, sometimes it is smaller. Here it is a subgroup of index two. The reason for my interest is an article of Estes and Pall, in which they show that the spinor kernel is precisely the fourth powers, two binary forms of the same discriminant are in the same genus if their ratio is a square, and in the same spinor genus if their ratio is a fourth power in the class group. If we take the principal form in $x,y,$ x^2 + ny^2,$then a form in the principal genus that is not a fourth power, then add some$cz^2,$k n^2 z^2,$ if there are no 2-adic problems the resulting ternary forms are in the same genus but distinct spinor genera. So this is a source of interesting examples.

3 added 807 characters in body; deleted 4 characters in body
2 added 312 characters in body
1