Iterative Strassen Algorithm

Question: I'm working on Parallel Programming and as part of a project (this is not homework) I'm trying to implement an iterative form of Strassens Algorithm using loops.
I understand how the recursive formulation works (credit to this and this), however I haven't found any resources (blogs or scientific literature) about an iterative formulation of the algorithm. I wanted to know if there's anyone here willing to share resources or implemented their own iterative version of the algorithm.
Thank you.
Comment: What is the difference between recursive and iterative?
Comment: What I mean by recursive is [this](https://martin-thoma.com/strassen-algorithm-in-python-java-cpp/), where the algorithm recursively calls upon itself in order to compute the product. We can always use a stack and convert a recursive algorithm to an iterative one (see [this](https://stackoverflow.com/questions/931762/can-every-recursion-be-converted-into-iteration)), but I was looking for a proper iterative algorithm using loops which unwinds the recursive tree (for an example see [this](https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/) which shows for Fibonacci numbers)
Comment: It might be inspiring to have a look at [Systolic Arrays](https://en.wikipedia.org/wiki/Systolic_array) and [Cannon's algorithm](https://en.wikipedia.org/wiki/Cannon%27s_algorithm).
Answer: Try to parallelize the following $8\times8\times8$ algorithm which is equivalent to a three-layer recursion of Strassen's $2\times2\times2$ algorithm:
<code>P01 := (a11+a22+a33+a44+a55+a66+a77+a88) * (b11+b22+b33+b44+b55+b66+b77+b88);
P02 := (a21+a22+a43+a44+a65+a66+a87+a88) * (b11+b33+b55+b77);
P03 := (a11+a33+a55+a77) * (b12-b22+b34-b44+b56-b66+b78-b88);
P04 := (a22+a44+a66+a88) * (-b11+b21-b33+b43-b55+b65-b77+b87);
P05 := (a11+a12+a33+a34+a55+a56+a77+a78) * (b22+b44+b66+b88);
P06 := (-a11+a21-a33+a43-a55+a65-a77+a87) * (b11+b12+b33+b34+b55+b56+b77+b78);
P07 := (a12-a22+a34-a44+a56-a66+a78-a88) * (b21+b22+b43+b44+b65+b66+b87+b88);
P08 := (a31+a33+a42+a44+a75+a77+a86+a88) * (b11+b22+b55+b66);
P09 := (a41+a42+a43+a44+a85+a86+a87+a88) * (b11+b55);
P10 := (a31+a33+a75+a77) * (b12-b22+b56-b66);
P11 := (a42+a44+a86+a88) * (-b11+b21-b55+b65);
P12 := (a31+a32+a33+a34+a75+a76+a77+a78) * (b22+b66);
P13 := (-a31-a33+a41+a43-a75-a77+a85+a87) * (b11+b12+b55+b56);
P14 := (a32+a34-a42-a44+a76+a78-a86-a88) * (b21+b22+b65+b66);
P15 := (a11+a22+a55+a66) * (b13+b24-b33-b44+b57+b68-b77-b88);
P16 := (a21+a22+a65+a66) * (b13-b33+b57-b77);
P17 := (a11+a55) * (b14-b24-b34+b44+b58-b68-b78+b88);
P18 := (a22+a66) * (-b13+b23+b33-b43-b57+b67+b77-b87);
P19 := (a11+a12+a55+a56) * (b24-b44+b68-b88);
P20 := (-a11+a21-a55+a65) * (b13+b14-b33-b34+b57+b58-b77-b78);
P21 := (a12-a22+a56-a66) * (b23+b24-b43-b44+b67+b68-b87-b88);
P22 := (a33+a44+a77+a88) * (-b11-b22+b31+b42-b55-b66+b75+b86);
P23 := (a43+a44+a87+a88) * (-b11+b31-b55+b75);
P24 := (a33+a77) * (-b12+b22+b32-b42-b56+b66+b76-b86);
P25 := (a44+a88) * (b11-b21-b31+b41+b55-b65-b75+b85);
P26 := (a33+a34+a77+a78) * (-b22+b42-b66+b86);
P27 := (-a33+a43-a77+a87) * (-b11-b12+b31+b32-b55-b56+b75+b76);
P28 := (a34-a44+a78-a88) * (-b21-b22+b41+b42-b65-b66+b85+b86);
P29 := (a11+a13+a22+a24+a55+a57+a66+a68) * (b33+b44+b77+b88);
P30 := (a21+a22+a23+a24+a65+a66+a67+a68) * (b33+b77);
P31 := (a11+a13+a55+a57) * (b34-b44+b78-b88);
P32 := (a22+a24+a66+a68) * (-b33+b43-b77+b87);
P33 := (a11+a12+a13+a14+a55+a56+a57+a58) * (b44+b88);
P34 := (-a11-a13+a21+a23-a55-a57+a65+a67) * (b33+b34+b77+b78);
P35 := (a12+a14-a22-a24+a56+a58-a66-a68) * (b43+b44+b87+b88);
P36 := (-a11-a22+a31+a42-a55-a66+a75+a86) * (b11+b13+b22+b24+b55+b57+b66+b68);
P37 := (-a21-a22+a41+a42-a65-a66+a85+a86) * (b11+b13+b55+b57);
P38 := (-a11+a31-a55+a75) * (b12+b14-b22-b24+b56+b58-b66-b68);
P39 := (-a22+a42-a66+a86) * (-b11-b13+b21+b23-b55-b57+b65+b67);
P40 := (-a11-a12+a31+a32-a55-a56+a75+a76) * (b22+b24+b66+b68);
P41 := (a11-a21-a31+a41+a55-a65-a75+a85) * (b11+b12+b13+b14+b55+b56+b57+b58);
P42 := (-a12+a22+a32-a42-a56+a66+a76-a86) * (b21+b22+b23+b24+b65+b66+b67+b68);
P43 := (a13+a24-a33-a44+a57+a68-a77-a88) * (b31+b33+b42+b44+b75+b77+b86+b88);
P44 := (a23+a24-a43-a44+a67+a68-a87-a88) * (b31+b33+b75+b77);
P45 := (a13-a33+a57-a77) * (b32+b34-b42-b44+b76+b78-b86-b88);
P46 := (a24-a44+a68-a88) * (-b31-b33+b41+b43-b75-b77+b85+b87);
P47 := (a13+a14-a33-a34+a57+a58-a77-a78) * (b42+b44+b86+b88);
P48 := (-a13+a23+a33-a43-a57+a67+a77-a87) * (b31+b32+b33+b34+b75+b76+b77+b78);
P49 := (a14-a24-a34+a44+a58-a68-a78+a88) * (b41+b42+b43+b44+b85+b86+b87+b88);
P50 := (a51+a55+a62+a66+a73+a77+a84+a88) * (b11+b22+b33+b44);
P51 := (a61+a62+a65+a66+a83+a84+a87+a88) * (b11+b33);
P52 := (a51+a55+a73+a77) * (b12-b22+b34-b44);
P53 := (a62+a66+a84+a88) * (-b11+b21-b33+b43);
P54 := (a51+a52+a55+a56+a73+a74+a77+a78) * (b22+b44);
P55 := (-a51-a55+a61+a65-a73-a77+a83+a87) * (b11+b12+b33+b34);
P56 := (a52+a56-a62-a66+a74+a78-a84-a88) * (b21+b22+b43+b44);
P57 := (a71+a73+a75+a77+a82+a84+a86+a88) * (b11+b22);
P58 := (a81+a82+a83+a84+a85+a86+a87+a88) * (b11);
P59 := (a71+a73+a75+a77) * (b12-b22);
P60 := (a82+a84+a86+a88) * (-b11+b21);
P61 := (a71+a72+a73+a74+a75+a76+a77+a78) * (b22);
P62 := (-a71-a73-a75-a77+a81+a83+a85+a87) * (b11+b12);
P63 := (a72+a74+a76+a78-a82-a84-a86-a88) * (b21+b22);
P64 := (a51+a55+a62+a66) * (b13+b24-b33-b44);
P65 := (a61+a62+a65+a66) * (b13-b33);
P66 := (a51+a55) * (b14-b24-b34+b44);
P67 := (a62+a66) * (-b13+b23+b33-b43);
P68 := (a51+a52+a55+a56) * (b24-b44);
P69 := (-a51-a55+a61+a65) * (b13+b14-b33-b34);
P70 := (a52+a56-a62-a66) * (b23+b24-b43-b44);
P71 := (a73+a77+a84+a88) * (-b11-b22+b31+b42);
P72 := (a83+a84+a87+a88) * (-b11+b31);
P73 := (a73+a77) * (-b12+b22+b32-b42);
P74 := (a84+a88) * (b11-b21-b31+b41);
P75 := (a73+a74+a77+a78) * (-b22+b42);
P76 := (-a73-a77+a83+a87) * (-b11-b12+b31+b32);
P77 := (a74+a78-a84-a88) * (-b21-b22+b41+b42);
P78 := (a51+a53+a55+a57+a62+a64+a66+a68) * (b33+b44);
P79 := (a61+a62+a63+a64+a65+a66+a67+a68) * (b33);
P80 := (a51+a53+a55+a57) * (b34-b44);
P81 := (a62+a64+a66+a68) * (-b33+b43);
P82 := (a51+a52+a53+a54+a55+a56+a57+a58) * (b44);
P83 := (-a51-a53-a55-a57+a61+a63+a65+a67) * (b33+b34);
P84 := (a52+a54+a56+a58-a62-a64-a66-a68) * (b43+b44);
P85 := (-a51-a55-a62-a66+a71+a75+a82+a86) * (b11+b13+b22+b24);
P86 := (-a61-a62-a65-a66+a81+a82+a85+a86) * (b11+b13);
P87 := (-a51-a55+a71+a75) * (b12+b14-b22-b24);
P88 := (-a62-a66+a82+a86) * (-b11-b13+b21+b23);
P89 := (-a51-a52-a55-a56+a71+a72+a75+a76) * (b22+b24);
P90 := (a51+a55-a61-a65-a71-a75+a81+a85) * (b11+b12+b13+b14);
P91 := (-a52-a56+a62+a66+a72+a76-a82-a86) * (b21+b22+b23+b24);
P92 := (a53+a57+a64+a68-a73-a77-a84-a88) * (b31+b33+b42+b44);
P93 := (a63+a64+a67+a68-a83-a84-a87-a88) * (b31+b33);
P94 := (a53+a57-a73-a77) * (b32+b34-b42-b44);
P95 := (a64+a68-a84-a88) * (-b31-b33+b41+b43);
P96 := (a53+a54+a57+a58-a73-a74-a77-a78) * (b42+b44);
P97 := (-a53-a57+a63+a67+a73+a77-a83-a87) * (b31+b32+b33+b34);
P98 := (a54+a58-a64-a68-a74-a78+a84+a88) * (b41+b42+b43+b44);
P99 := (a11+a22+a33+a44) * (b15+b26+b37+b48-b55-b66-b77-b88);
P100 := (a21+a22+a43+a44) * (b15+b37-b55-b77);
P101 := (a11+a33) * (b16-b26+b38-b48-b56+b66-b78+b88);
P102 := (a22+a44) * (-b15+b25-b37+b47+b55-b65+b77-b87);
P103 := (a11+a12+a33+a34) * (b26+b48-b66-b88);
P104 := (-a11+a21-a33+a43) * (b15+b16+b37+b38-b55-b56-b77-b78);
P105 := (a12-a22+a34-a44) * (b25+b26+b47+b48-b65-b66-b87-b88);
P106 := (a31+a33+a42+a44) * (b15+b26-b55-b66);
P107 := (a41+a42+a43+a44) * (b15-b55);
P108 := (a31+a33) * (b16-b26-b56+b66);
P109 := (a42+a44) * (-b15+b25+b55-b65);
P110 := (a31+a32+a33+a34) * (b26-b66);
P111 := (-a31-a33+a41+a43) * (b15+b16-b55-b56);
P112 := (a32+a34-a42-a44) * (b25+b26-b65-b66);
P113 := (a11+a22) * (b17+b28-b37-b48-b57-b68+b77+b88);
P114 := (a21+a22) * (b17-b37-b57+b77);
P115 := (a11) * (b18-b28-b38+b48-b58+b68+b78-b88);
P116 := (a22) * (-b17+b27+b37-b47+b57-b67-b77+b87);
P117 := (a11+a12) * (b28-b48-b68+b88);
P118 := (-a11+a21) * (b17+b18-b37-b38-b57-b58+b77+b78);
P119 := (a12-a22) * (b27+b28-b47-b48-b67-b68+b87+b88);
P120 := (a33+a44) * (-b15-b26+b35+b46+b55+b66-b75-b86);
P121 := (a43+a44) * (-b15+b35+b55-b75);
P122 := (a33) * (-b16+b26+b36-b46+b56-b66-b76+b86);
P123 := (a44) * (b15-b25-b35+b45-b55+b65+b75-b85);
P124 := (a33+a34) * (-b26+b46+b66-b86);
P125 := (-a33+a43) * (-b15-b16+b35+b36+b55+b56-b75-b76);
P126 := (a34-a44) * (-b25-b26+b45+b46+b65+b66-b85-b86);
P127 := (a11+a13+a22+a24) * (b37+b48-b77-b88);
P128 := (a21+a22+a23+a24) * (b37-b77);
P129 := (a11+a13) * (b38-b48-b78+b88);
P130 := (a22+a24) * (-b37+b47+b77-b87);
P131 := (a11+a12+a13+a14) * (b48-b88);
P132 := (-a11-a13+a21+a23) * (b37+b38-b77-b78);
P133 := (a12+a14-a22-a24) * (b47+b48-b87-b88);
P134 := (-a11-a22+a31+a42) * (b15+b17+b26+b28-b55-b57-b66-b68);
P135 := (-a21-a22+a41+a42) * (b15+b17-b55-b57);
P136 := (-a11+a31) * (b16+b18-b26-b28-b56-b58+b66+b68);
P137 := (-a22+a42) * (-b15-b17+b25+b27+b55+b57-b65-b67);
P138 := (-a11-a12+a31+a32) * (b26+b28-b66-b68);
P139 := (a11-a21-a31+a41) * (b15+b16+b17+b18-b55-b56-b57-b58);
P140 := (-a12+a22+a32-a42) * (b25+b26+b27+b28-b65-b66-b67-b68);
P141 := (a13+a24-a33-a44) * (b35+b37+b46+b48-b75-b77-b86-b88);
P142 := (a23+a24-a43-a44) * (b35+b37-b75-b77);
P143 := (a13-a33) * (b36+b38-b46-b48-b76-b78+b86+b88);
P144 := (a24-a44) * (-b35-b37+b45+b47+b75+b77-b85-b87);
P145 := (a13+a14-a33-a34) * (b46+b48-b86-b88);
P146 := (-a13+a23+a33-a43) * (b35+b36+b37+b38-b75-b76-b77-b78);
P147 := (a14-a24-a34+a44) * (b45+b46+b47+b48-b85-b86-b87-b88);
P148 := (a55+a66+a77+a88) * (-b11-b22-b33-b44+b51+b62+b73+b84);
P149 := (a65+a66+a87+a88) * (-b11-b33+b51+b73);
P150 := (a55+a77) * (-b12+b22-b34+b44+b52-b62+b74-b84);
P151 := (a66+a88) * (b11-b21+b33-b43-b51+b61-b73+b83);
P152 := (a55+a56+a77+a78) * (-b22-b44+b62+b84);
P153 := (-a55+a65-a77+a87) * (-b11-b12-b33-b34+b51+b52+b73+b74);
P154 := (a56-a66+a78-a88) * (-b21-b22-b43-b44+b61+b62+b83+b84);
P155 := (a75+a77+a86+a88) * (-b11-b22+b51+b62);
P156 := (a85+a86+a87+a88) * (-b11+b51);
P157 := (a75+a77) * (-b12+b22+b52-b62);
P158 := (a86+a88) * (b11-b21-b51+b61);
P159 := (a75+a76+a77+a78) * (-b22+b62);
P160 := (-a75-a77+a85+a87) * (-b11-b12+b51+b52);
P161 := (a76+a78-a86-a88) * (-b21-b22+b61+b62);
P162 := (a55+a66) * (-b13-b24+b33+b44+b53+b64-b73-b84);
P163 := (a65+a66) * (-b13+b33+b53-b73);
P164 := (a55) * (-b14+b24+b34-b44+b54-b64-b74+b84);
P165 := (a66) * (b13-b23-b33+b43-b53+b63+b73-b83);
P166 := (a55+a56) * (-b24+b44+b64-b84);
P167 := (-a55+a65) * (-b13-b14+b33+b34+b53+b54-b73-b74);
P168 := (a56-a66) * (-b23-b24+b43+b44+b63+b64-b83-b84);
P169 := (a77+a88) * (b11+b22-b31-b42-b51-b62+b71+b82);
P170 := (a87+a88) * (b11-b31-b51+b71);
P171 := (a77) * (b12-b22-b32+b42-b52+b62+b72-b82);
P172 := (a88) * (-b11+b21+b31-b41+b51-b61-b71+b81);
P173 := (a77+a78) * (b22-b42-b62+b82);
P174 := (-a77+a87) * (b11+b12-b31-b32-b51-b52+b71+b72);
P175 := (a78-a88) * (b21+b22-b41-b42-b61-b62+b81+b82);
P176 := (a55+a57+a66+a68) * (-b33-b44+b73+b84);
P177 := (a65+a66+a67+a68) * (-b33+b73);
P178 := (a55+a57) * (-b34+b44+b74-b84);
P179 := (a66+a68) * (b33-b43-b73+b83);
P180 := (a55+a56+a57+a58) * (-b44+b84);
P181 := (-a55-a57+a65+a67) * (-b33-b34+b73+b74);
P182 := (a56+a58-a66-a68) * (-b43-b44+b83+b84);
P183 := (-a55-a66+a75+a86) * (-b11-b13-b22-b24+b51+b53+b62+b64);
P184 := (-a65-a66+a85+a86) * (-b11-b13+b51+b53);
P185 := (-a55+a75) * (-b12-b14+b22+b24+b52+b54-b62-b64);
P186 := (-a66+a86) * (b11+b13-b21-b23-b51-b53+b61+b63);
P187 := (-a55-a56+a75+a76) * (-b22-b24+b62+b64);
P188 := (a55-a65-a75+a85) * (-b11-b12-b13-b14+b51+b52+b53+b54);
P189 := (-a56+a66+a76-a86) * (-b21-b22-b23-b24+b61+b62+b63+b64);
P190 := (a57+a68-a77-a88) * (-b31-b33-b42-b44+b71+b73+b82+b84);
P191 := (a67+a68-a87-a88) * (-b31-b33+b71+b73);
P192 := (a57-a77) * (-b32-b34+b42+b44+b72+b74-b82-b84);
P193 := (a68-a88) * (b31+b33-b41-b43-b71-b73+b81+b83);
P194 := (a57+a58-a77-a78) * (-b42-b44+b82+b84);
P195 := (-a57+a67+a77-a87) * (-b31-b32-b33-b34+b71+b72+b73+b74);
P196 := (a58-a68-a78+a88) * (-b41-b42-b43-b44+b81+b82+b83+b84);
P197 := (a11+a15+a22+a26+a33+a37+a44+a48) * (b55+b66+b77+b88);
P198 := (a21+a22+a25+a26+a43+a44+a47+a48) * (b55+b77);
P199 := (a11+a15+a33+a37) * (b56-b66+b78-b88);
P200 := (a22+a26+a44+a48) * (-b55+b65-b77+b87);
P201 := (a11+a12+a15+a16+a33+a34+a37+a38) * (b66+b88);
P202 := (-a11-a15+a21+a25-a33-a37+a43+a47) * (b55+b56+b77+b78);
P203 := (a12+a16-a22-a26+a34+a38-a44-a48) * (b65+b66+b87+b88);
P204 := (a31+a33+a35+a37+a42+a44+a46+a48) * (b55+b66);
P205 := (a41+a42+a43+a44+a45+a46+a47+a48) * (b55);
P206 := (a31+a33+a35+a37) * (b56-b66);
P207 := (a42+a44+a46+a48) * (-b55+b65);
P208 := (a31+a32+a33+a34+a35+a36+a37+a38) * (b66);
P209 := (-a31-a33-a35-a37+a41+a43+a45+a47) * (b55+b56);
P210 := (a32+a34+a36+a38-a42-a44-a46-a48) * (b65+b66);
P211 := (a11+a15+a22+a26) * (b57+b68-b77-b88);
P212 := (a21+a22+a25+a26) * (b57-b77);
P213 := (a11+a15) * (b58-b68-b78+b88);
P214 := (a22+a26) * (-b57+b67+b77-b87);
P215 := (a11+a12+a15+a16) * (b68-b88);
P216 := (-a11-a15+a21+a25) * (b57+b58-b77-b78);
P217 := (a12+a16-a22-a26) * (b67+b68-b87-b88);
P218 := (a33+a37+a44+a48) * (-b55-b66+b75+b86);
P219 := (a43+a44+a47+a48) * (-b55+b75);
P220 := (a33+a37) * (-b56+b66+b76-b86);
P221 := (a44+a48) * (b55-b65-b75+b85);
P222 := (a33+a34+a37+a38) * (-b66+b86);
P223 := (-a33-a37+a43+a47) * (-b55-b56+b75+b76);
P224 := (a34+a38-a44-a48) * (-b65-b66+b85+b86);
P225 := (a11+a13+a15+a17+a22+a24+a26+a28) * (b77+b88);
P226 := (a21+a22+a23+a24+a25+a26+a27+a28) * (b77);
P227 := (a11+a13+a15+a17) * (b78-b88);
P228 := (a22+a24+a26+a28) * (-b77+b87);
P229 := (a11+a12+a13+a14+a15+a16+a17+a18) * (b88);
P230 := (-a11-a13-a15-a17+a21+a23+a25+a27) * (b77+b78);
P231 := (a12+a14+a16+a18-a22-a24-a26-a28) * (b87+b88);
P232 := (-a11-a15-a22-a26+a31+a35+a42+a46) * (b55+b57+b66+b68);
P233 := (-a21-a22-a25-a26+a41+a42+a45+a46) * (b55+b57);
P234 := (-a11-a15+a31+a35) * (b56+b58-b66-b68);
P235 := (-a22-a26+a42+a46) * (-b55-b57+b65+b67);
P236 := (-a11-a12-a15-a16+a31+a32+a35+a36) * (b66+b68);
P237 := (a11+a15-a21-a25-a31-a35+a41+a45) * (b55+b56+b57+b58);
P238 := (-a12-a16+a22+a26+a32+a36-a42-a46) * (b65+b66+b67+b68);
P239 := (a13+a17+a24+a28-a33-a37-a44-a48) * (b75+b77+b86+b88);
P240 := (a23+a24+a27+a28-a43-a44-a47-a48) * (b75+b77);
P241 := (a13+a17-a33-a37) * (b76+b78-b86-b88);
P242 := (a24+a28-a44-a48) * (-b75-b77+b85+b87);
P243 := (a13+a14+a17+a18-a33-a34-a37-a38) * (b86+b88);
P244 := (-a13-a17+a23+a27+a33+a37-a43-a47) * (b75+b76+b77+b78);
P245 := (a14+a18-a24-a28-a34-a38+a44+a48) * (b85+b86+b87+b88);
P246 := (-a11-a22-a33-a44+a51+a62+a73+a84) * (b11+b15+b22+b26+b33+b37+b44+b48);
P247 := (-a21-a22-a43-a44+a61+a62+a83+a84) * (b11+b15+b33+b37);
P248 := (-a11-a33+a51+a73) * (b12+b16-b22-b26+b34+b38-b44-b48);
P249 := (-a22-a44+a62+a84) * (-b11-b15+b21+b25-b33-b37+b43+b47);
P250 := (-a11-a12-a33-a34+a51+a52+a73+a74) * (b22+b26+b44+b48);
P251 := (a11-a21+a33-a43-a51+a61-a73+a83) * (b11+b12+b15+b16+b33+b34+b37+b38);
P252 := (-a12+a22-a34+a44+a52-a62+a74-a84) * (b21+b22+b25+b26+b43+b44+b47+b48);
P253 := (-a31-a33-a42-a44+a71+a73+a82+a84) * (b11+b15+b22+b26);
P254 := (-a41-a42-a43-a44+a81+a82+a83+a84) * (b11+b15);
P255 := (-a31-a33+a71+a73) * (b12+b16-b22-b26);
P256 := (-a42-a44+a82+a84) * (-b11-b15+b21+b25);
P257 := (-a31-a32-a33-a34+a71+a72+a73+a74) * (b22+b26);
P258 := (a31+a33-a41-a43-a71-a73+a81+a83) * (b11+b12+b15+b16);
P259 := (-a32-a34+a42+a44+a72+a74-a82-a84) * (b21+b22+b25+b26);
P260 := (-a11-a22+a51+a62) * (b13+b17+b24+b28-b33-b37-b44-b48);
P261 := (-a21-a22+a61+a62) * (b13+b17-b33-b37);
P262 := (-a11+a51) * (b14+b18-b24-b28-b34-b38+b44+b48);
P263 := (-a22+a62) * (-b13-b17+b23+b27+b33+b37-b43-b47);
P264 := (-a11-a12+a51+a52) * (b24+b28-b44-b48);
P265 := (a11-a21-a51+a61) * (b13+b14+b17+b18-b33-b34-b37-b38);
P266 := (-a12+a22+a52-a62) * (b23+b24+b27+b28-b43-b44-b47-b48);
P267 := (-a33-a44+a73+a84) * (-b11-b15-b22-b26+b31+b35+b42+b46);
P268 := (-a43-a44+a83+a84) * (-b11-b15+b31+b35);
P269 := (-a33+a73) * (-b12-b16+b22+b26+b32+b36-b42-b46);
P270 := (-a44+a84) * (b11+b15-b21-b25-b31-b35+b41+b45);
P271 := (-a33-a34+a73+a74) * (-b22-b26+b42+b46);
P272 := (a33-a43-a73+a83) * (-b11-b12-b15-b16+b31+b32+b35+b36);
P273 := (-a34+a44+a74-a84) * (-b21-b22-b25-b26+b41+b42+b45+b46);
P274 := (-a11-a13-a22-a24+a51+a53+a62+a64) * (b33+b37+b44+b48);
P275 := (-a21-a22-a23-a24+a61+a62+a63+a64) * (b33+b37);
P276 := (-a11-a13+a51+a53) * (b34+b38-b44-b48);
P277 := (-a22-a24+a62+a64) * (-b33-b37+b43+b47);
P278 := (-a11-a12-a13-a14+a51+a52+a53+a54) * (b44+b48);
P279 := (a11+a13-a21-a23-a51-a53+a61+a63) * (b33+b34+b37+b38);
P280 := (-a12-a14+a22+a24+a52+a54-a62-a64) * (b43+b44+b47+b48);
P281 := (a11+a22-a31-a42-a51-a62+a71+a82) * (b11+b13+b15+b17+b22+b24+b26+b28);
P282 := (a21+a22-a41-a42-a61-a62+a81+a82) * (b11+b13+b15+b17);
P283 := (a11-a31-a51+a71) * (b12+b14+b16+b18-b22-b24-b26-b28);
P284 := (a22-a42-a62+a82) * (-b11-b13-b15-b17+b21+b23+b25+b27);
P285 := (a11+a12-a31-a32-a51-a52+a71+a72) * (b22+b24+b26+b28);
P286 := (-a11+a21+a31-a41+a51-a61-a71+a81) * (b11+b12+b13+b14+b15+b16+b17+b18);
P287 := (a12-a22-a32+a42-a52+a62+a72-a82) * (b21+b22+b23+b24+b25+b26+b27+b28);
P288 := (-a13-a24+a33+a44+a53+a64-a73-a84) * (b31+b33+b35+b37+b42+b44+b46+b48);
P289 := (-a23-a24+a43+a44+a63+a64-a83-a84) * (b31+b33+b35+b37);
P290 := (-a13+a33+a53-a73) * (b32+b34+b36+b38-b42-b44-b46-b48);
P291 := (-a24+a44+a64-a84) * (-b31-b33-b35-b37+b41+b43+b45+b47);
P292 := (-a13-a14+a33+a34+a53+a54-a73-a74) * (b42+b44+b46+b48);
P293 := (a13-a23-a33+a43-a53+a63+a73-a83) * (b31+b32+b33+b34+b35+b36+b37+b38);
P294 := (-a14+a24+a34-a44+a54-a64-a74+a84) * (b41+b42+b43+b44+b45+b46+b47+b48);
P295 := (a15+a26+a37+a48-a55-a66-a77-a88) * (b51+b55+b62+b66+b73+b77+b84+b88);
P296 := (a25+a26+a47+a48-a65-a66-a87-a88) * (b51+b55+b73+b77);
P297 := (a15+a37-a55-a77) * (b52+b56-b62-b66+b74+b78-b84-b88);
P298 := (a26+a48-a66-a88) * (-b51-b55+b61+b65-b73-b77+b83+b87);
P299 := (a15+a16+a37+a38-a55-a56-a77-a78) * (b62+b66+b84+b88);
P300 := (-a15+a25-a37+a47+a55-a65+a77-a87) * (b51+b52+b55+b56+b73+b74+b77+b78);
P301 := (a16-a26+a38-a48-a56+a66-a78+a88) * (b61+b62+b65+b66+b83+b84+b87+b88);
P302 := (a35+a37+a46+a48-a75-a77-a86-a88) * (b51+b55+b62+b66);
P303 := (a45+a46+a47+a48-a85-a86-a87-a88) * (b51+b55);
P304 := (a35+a37-a75-a77) * (b52+b56-b62-b66);
P305 := (a46+a48-a86-a88) * (-b51-b55+b61+b65);
P306 := (a35+a36+a37+a38-a75-a76-a77-a78) * (b62+b66);
P307 := (-a35-a37+a45+a47+a75+a77-a85-a87) * (b51+b52+b55+b56);
P308 := (a36+a38-a46-a48-a76-a78+a86+a88) * (b61+b62+b65+b66);
P309 := (a15+a26-a55-a66) * (b53+b57+b64+b68-b73-b77-b84-b88);
P310 := (a25+a26-a65-a66) * (b53+b57-b73-b77);
P311 := (a15-a55) * (b54+b58-b64-b68-b74-b78+b84+b88);
P312 := (a26-a66) * (-b53-b57+b63+b67+b73+b77-b83-b87);
P313 := (a15+a16-a55-a56) * (b64+b68-b84-b88);
P314 := (-a15+a25+a55-a65) * (b53+b54+b57+b58-b73-b74-b77-b78);
P315 := (a16-a26-a56+a66) * (b63+b64+b67+b68-b83-b84-b87-b88);
P316 := (a37+a48-a77-a88) * (-b51-b55-b62-b66+b71+b75+b82+b86);
P317 := (a47+a48-a87-a88) * (-b51-b55+b71+b75);
P318 := (a37-a77) * (-b52-b56+b62+b66+b72+b76-b82-b86);
P319 := (a48-a88) * (b51+b55-b61-b65-b71-b75+b81+b85);
P320 := (a37+a38-a77-a78) * (-b62-b66+b82+b86);
P321 := (-a37+a47+a77-a87) * (-b51-b52-b55-b56+b71+b72+b75+b76);
P322 := (a38-a48-a78+a88) * (-b61-b62-b65-b66+b81+b82+b85+b86);
P323 := (a15+a17+a26+a28-a55-a57-a66-a68) * (b73+b77+b84+b88);
P324 := (a25+a26+a27+a28-a65-a66-a67-a68) * (b73+b77);
P325 := (a15+a17-a55-a57) * (b74+b78-b84-b88);
P326 := (a26+a28-a66-a68) * (-b73-b77+b83+b87);
P327 := (a15+a16+a17+a18-a55-a56-a57-a58) * (b84+b88);
P328 := (-a15-a17+a25+a27+a55+a57-a65-a67) * (b73+b74+b77+b78);
P329 := (a16+a18-a26-a28-a56-a58+a66+a68) * (b83+b84+b87+b88);
P330 := (-a15-a26+a35+a46+a55+a66-a75-a86) * (b51+b53+b55+b57+b62+b64+b66+b68);
P331 := (-a25-a26+a45+a46+a65+a66-a85-a86) * (b51+b53+b55+b57);
P332 := (-a15+a35+a55-a75) * (b52+b54+b56+b58-b62-b64-b66-b68);
P333 := (-a26+a46+a66-a86) * (-b51-b53-b55-b57+b61+b63+b65+b67);
P334 := (-a15-a16+a35+a36+a55+a56-a75-a76) * (b62+b64+b66+b68);
P335 := (a15-a25-a35+a45-a55+a65+a75-a85) * (b51+b52+b53+b54+b55+b56+b57+b58);
P336 := (-a16+a26+a36-a46+a56-a66-a76+a86) * (b61+b62+b63+b64+b65+b66+b67+b68);
P337 := (a17+a28-a37-a48-a57-a68+a77+a88) * (b71+b73+b75+b77+b82+b84+b86+b88);
P338 := (a27+a28-a47-a48-a67-a68+a87+a88) * (b71+b73+b75+b77);
P339 := (a17-a37-a57+a77) * (b72+b74+b76+b78-b82-b84-b86-b88);
P340 := (a28-a48-a68+a88) * (-b71-b73-b75-b77+b81+b83+b85+b87);
P341 := (a17+a18-a37-a38-a57-a58+a77+a78) * (b82+b84+b86+b88);
P342 := (-a17+a27+a37-a47+a57-a67-a77+a87) * (b71+b72+b73+b74+b75+b76+b77+b78);
P343 := (a18-a28-a38+a48-a58+a68+a78-a88) * (b81+b82+b83+b84+b85+b86+b87+b88);

c11 := P01+P04-P05+P07+P22+P25-P26+P28-P29-P32+P33-P35+P43+P46-P47+P49+P148+P151-P152+P154+P169+P172-P173+P175-P176-P179+P180-P182+P190+P193-P194+P196-P197-P200+P201-P203-P218-P221+P222-P224+P225+P228-P229+P231-P239-P242+P243-P245+P295+P298-P299+P301+P316+P319-P320+P322-P323-P326+P327-P329+P337+P340-P341+P343;
c12 := P03+P05+P24+P26-P31-P33+P45+P47+P150+P152+P171+P173-P178-P180+P192+P194-P199-P201-P220-P222+P227+P229-P241-P243+P297+P299+P318+P320-P325-P327+P339+P341;
c13 := P15+P18-P19+P21+P29+P32-P33+P35+P162+P165-P166+P168+P176+P179-P180+P182-P211-P214+P215-P217-P225-P228+P229-P231+P309+P312-P313+P315+P323+P326-P327+P329;
c14 := P17+P19+P31+P33+P164+P166+P178+P180-P213-P215-P227-P229+P311+P313+P325+P327;
c15 := P99+P102-P103+P105+P120+P123-P124+P126-P127-P130+P131-P133+P141+P144-P145+P147+P197+P200-P201+P203+P218+P221-P222+P224-P225-P228+P229-P231+P239+P242-P243+P245;
c16 := P101+P103+P122+P124-P129-P131+P143+P145+P199+P201+P220+P222-P227-P229+P241+P243;
c17 := P113+P116-P117+P119+P127+P130-P131+P133+P211+P214-P215+P217+P225+P228-P229+P231;
c18 := P115+P117+P129+P131+P213+P215+P227+P229;
c21 := P02+P04+P23+P25-P30-P32+P44+P46+P149+P151+P170+P172-P177-P179+P191+P193-P198-P200-P219-P221+P226+P228-P240-P242+P296+P298+P317+P319-P324-P326+P338+P340;
c22 := P01-P02+P03+P06+P22-P23+P24+P27-P29+P30-P31-P34+P43-P44+P45+P48+P148-P149+P150+P153+P169-P170+P171+P174-P176+P177-P178-P181+P190-P191+P192+P195-P197+P198-P199-P202-P218+P219-P220-P223+P225-P226+P227+P230-P239+P240-P241-P244+P295-P296+P297+P300+P316-P317+P318+P321-P323+P324-P325-P328+P337-P338+P339+P342;
c23 := P16+P18+P30+P32+P163+P165+P177+P179-P212-P214-P226-P228+P310+P312+P324+P326;
c24 := P15-P16+P17+P20+P29-P30+P31+P34+P162-P163+P164+P167+P176-P177+P178+P181-P211+P212-P213-P216-P225+P226-P227-P230+P309-P310+P311+P314+P323-P324+P325+P328;
c25 := P100+P102+P121+P123-P128-P130+P142+P144+P198+P200+P219+P221-P226-P228+P240+P242;
c26 := P99-P100+P101+P104+P120-P121+P122+P125-P127+P128-P129-P132+P141-P142+P143+P146+P197-P198+P199+P202+P218-P219+P220+P223-P225+P226-P227-P230+P239-P240+P241+P244;
c27 := P114+P116+P128+P130+P212+P214+P226+P228;
c28 := P113-P114+P115+P118+P127-P128+P129+P132+P211-P212+P213+P216+P225-P226+P227+P230;
c31 := P08+P11-P12+P14+P22+P25-P26+P28+P155+P158-P159+P161+P169+P172-P173+P175-P204-P207+P208-P210-P218-P221+P222-P224+P302+P305-P306+P308+P316+P319-P320+P322;
c32 := P10+P12+P24+P26+P157+P159+P171+P173-P206-P208-P220-P222+P304+P306+P318+P320;
c33 := P01+P04-P05+P07-P08-P11+P12-P14+P15+P18-P19+P21+P36+P39-P40+P42+P148+P151-P152+P154-P155-P158+P159-P161+P162+P165-P166+P168+P183+P186-P187+P189-P197-P200+P201-P203+P204+P207-P208+P210-P211-P214+P215-P217-P232-P235+P236-P238+P295+P298-P299+P301-P302-P305+P306-P308+P309+P312-P313+P315+P330+P333-P334+P336;
c34 := P03+P05-P10-P12+P17+P19+P38+P40+P150+P152-P157-P159+P164+P166+P185+P187-P199-P201+P206+P208-P213-P215-P234-P236+P297+P299-P304-P306+P311+P313+P332+P334;
c35 := P106+P109-P110+P112+P120+P123-P124+P126+P204+P207-P208+P210+P218+P221-P222+P224;
c36 := P108+P110+P122+P124+P206+P208+P220+P222;
c37 := P99+P102-P103+P105-P106-P109+P110-P112+P113+P116-P117+P119+P134+P137-P138+P140+P197+P200-P201+P203-P204-P207+P208-P210+P211+P214-P215+P217+P232+P235-P236+P238;
c38 := P101+P103-P108-P110+P115+P117+P136+P138+P199+P201-P206-P208+P213+P215+P234+P236;
c41 := P09+P11+P23+P25+P156+P158+P170+P172-P205-P207-P219-P221+P303+P305+P317+P319;
c42 := P08-P09+P10+P13+P22-P23+P24+P27+P155-P156+P157+P160+P169-P170+P171+P174-P204+P205-P206-P209-P218+P219-P220-P223+P302-P303+P304+P307+P316-P317+P318+P321;
c43 := P02+P04-P09-P11+P16+P18+P37+P39+P149+P151-P156-P158+P163+P165+P184+P186-P198-P200+P205+P207-P212-P214-P233-P235+P296+P298-P303-P305+P310+P312+P331+P333;
c44 := P01-P02+P03+P06-P08+P09-P10-P13+P15-P16+P17+P20+P36-P37+P38+P41+P148-P149+P150+P153-P155+P156-P157-P160+P162-P163+P164+P167+P183-P184+P185+P188-P197+P198-P199-P202+P204-P205+P206+P209-P211+P212-P213-P216-P232+P233-P234-P237+P295-P296+P297+P300-P302+P303-P304-P307+P309-P310+P311+P314+P330-P331+P332+P335;
c45 := P107+P109+P121+P123+P205+P207+P219+P221;
c46 := P106-P107+P108+P111+P120-P121+P122+P125+P204-P205+P206+P209+P218-P219+P220+P223;
c47 := P100+P102-P107-P109+P114+P116+P135+P137+P198+P200-P205-P207+P212+P214+P233+P235;
c48 := P99-P100+P101+P104-P106+P107-P108-P111+P113-P114+P115+P118+P134-P135+P136+P139+P197-P198+P199+P202-P204+P205-P206-P209+P211-P212+P213+P216+P232-P233+P234+P237;
c51 := P50+P53-P54+P56+P71+P74-P75+P77-P78-P81+P82-P84+P92+P95-P96+P98+P148+P151-P152+P154+P169+P172-P173+P175-P176-P179+P180-P182+P190+P193-P194+P196;
c52 := P52+P54+P73+P75-P80-P82+P94+P96+P150+P152+P171+P173-P178-P180+P192+P194;
c53 := P64+P67-P68+P70+P78+P81-P82+P84+P162+P165-P166+P168+P176+P179-P180+P182;
c54 := P66+P68+P80+P82+P164+P166+P178+P180;
c55 := P01+P04-P05+P07+P22+P25-P26+P28-P29-P32+P33-P35+P43+P46-P47+P49-P50-P53+P54-P56-P71-P74+P75-P77+P78+P81-P82+P84-P92-P95+P96-P98+P99+P102-P103+P105+P120+P123-P124+P126-P127-P130+P131-P133+P141+P144-P145+P147+P246+P249-P250+P252+P267+P270-P271+P273-P274-P277+P278-P280+P288+P291-P292+P294;
c56 := P03+P05+P24+P26-P31-P33+P45+P47-P52-P54-P73-P75+P80+P82-P94-P96+P101+P103+P122+P124-P129-P131+P143+P145+P248+P250+P269+P271-P276-P278+P290+P292;
c57 := P15+P18-P19+P21+P29+P32-P33+P35-P64-P67+P68-P70-P78-P81+P82-P84+P113+P116-P117+P119+P127+P130-P131+P133+P260+P263-P264+P266+P274+P277-P278+P280;
c58 := P17+P19+P31+P33-P66-P68-P80-P82+P115+P117+P129+P131+P262+P264+P276+P278;
c61 := P51+P53+P72+P74-P79-P81+P93+P95+P149+P151+P170+P172-P177-P179+P191+P193;
c62 := P50-P51+P52+P55+P71-P72+P73+P76-P78+P79-P80-P83+P92-P93+P94+P97+P148-P149+P150+P153+P169-P170+P171+P174-P176+P177-P178-P181+P190-P191+P192+P195;
c63 := P65+P67+P79+P81+P163+P165+P177+P179;
c64 := P64-P65+P66+P69+P78-P79+P80+P83+P162-P163+P164+P167+P176-P177+P178+P181;
c65 := P02+P04+P23+P25-P30-P32+P44+P46-P51-P53-P72-P74+P79+P81-P93-P95+P100+P102+P121+P123-P128-P130+P142+P144+P247+P249+P268+P270-P275-P277+P289+P291;
c66 := P01-P02+P03+P06+P22-P23+P24+P27-P29+P30-P31-P34+P43-P44+P45+P48-P50+P51-P52-P55-P71+P72-P73-P76+P78-P79+P80+P83-P92+P93-P94-P97+P99-P100+P101+P104+P120-P121+P122+P125-P127+P128-P129-P132+P141-P142+P143+P146+P246-P247+P248+P251+P267-P268+P269+P272-P274+P275-P276-P279+P288-P289+P290+P293;
c67 := P16+P18+P30+P32-P65-P67-P79-P81+P114+P116+P128+P130+P261+P263+P275+P277;
c68 := P15-P16+P17+P20+P29-P30+P31+P34-P64+P65-P66-P69-P78+P79-P80-P83+P113-P114+P115+P118+P127-P128+P129+P132+P260-P261+P262+P265+P274-P275+P276+P279;
c71 := P57+P60-P61+P63+P71+P74-P75+P77+P155+P158-P159+P161+P169+P172-P173+P175;
c72 := P59+P61+P73+P75+P157+P159+P171+P173;
c73 := P50+P53-P54+P56-P57-P60+P61-P63+P64+P67-P68+P70+P85+P88-P89+P91+P148+P151-P152+P154-P155-P158+P159-P161+P162+P165-P166+P168+P183+P186-P187+P189;
c74 := P52+P54-P59-P61+P66+P68+P87+P89+P150+P152-P157-P159+P164+P166+P185+P187;
c75 := P08+P11-P12+P14+P22+P25-P26+P28-P57-P60+P61-P63-P71-P74+P75-P77+P106+P109-P110+P112+P120+P123-P124+P126+P253+P256-P257+P259+P267+P270-P271+P273;
c76 := P10+P12+P24+P26-P59-P61-P73-P75+P108+P110+P122+P124+P255+P257+P269+P271;
c77 := P01+P04-P05+P07-P08-P11+P12-P14+P15+P18-P19+P21+P36+P39-P40+P42-P50-P53+P54-P56+P57+P60-P61+P63-P64-P67+P68-P70-P85-P88+P89-P91+P99+P102-P103+P105-P106-P109+P110-P112+P113+P116-P117+P119+P134+P137-P138+P140+P246+P249-P250+P252-P253-P256+P257-P259+P260+P263-P264+P266+P281+P284-P285+P287;
c78 := P03+P05-P10-P12+P17+P19+P38+P40-P52-P54+P59+P61-P66-P68-P87-P89+P101+P103-P108-P110+P115+P117+P136+P138+P248+P250-P255-P257+P262+P264+P283+P285;
c81 := P58+P60+P72+P74+P156+P158+P170+P172;
c82 := P57-P58+P59+P62+P71-P72+P73+P76+P155-P156+P157+P160+P169-P170+P171+P174;
c83 := P51+P53-P58-P60+P65+P67+P86+P88+P149+P151-P156-P158+P163+P165+P184+P186;
c84 := P50-P51+P52+P55-P57+P58-P59-P62+P64-P65+P66+P69+P85-P86+P87+P90+P148-P149+P150+P153-P155+P156-P157-P160+P162-P163+P164+P167+P183-P184+P185+P188;
c85 := P09+P11+P23+P25-P58-P60-P72-P74+P107+P109+P121+P123+P254+P256+P268+P270;
c86 := P08-P09+P10+P13+P22-P23+P24+P27-P57+P58-P59-P62-P71+P72-P73-P76+P106-P107+P108+P111+P120-P121+P122+P125+P253-P254+P255+P258+P267-P268+P269+P272;
c87 := P02+P04-P09-P11+P16+P18+P37+P39-P51-P53+P58+P60-P65-P67-P86-P88+P100+P102-P107-P109+P114+P116+P135+P137+P247+P249-P254-P256+P261+P263+P282+P284;
c88 := P01-P02+P03+P06-P08+P09-P10-P13+P15-P16+P17+P20+P36-P37+P38+P41-P50+P51-P52-P55+P57-P58+P59+P62-P64+P65-P66-P69-P85+P86-P87-P90+P99-P100+P101+P104-P106+P107-P108-P111+P113-P114+P115+P118+P134-P135+P136+P139+P246-P247+P248+P251-P253+P254-P255-P258+P260-P261+P262+P265+P281-P282+P283+P286;
</code>

Iterative Strassen Algorithm


Argumentos incompatíveis - Ponteiros para estruturas

Question: Boa tarde,
Precisava de ajuda a corrigir uns erros no terminal.
Resumo:
Fiz algumas funções para obter uma certa informaçao (valores) sobre clientes ativos (em que um cliente é ativo se for emitente ou benefeciario de um cheque por processar). É um sistema de cheques e clientes
Estou a usar estruturas, árvores e ponteiros mas tenho  erros no terminal penso eu que sejam de ter utilizado mal os ponteiros.. ou então as funçoes estão mal feitas.
Tenho um ficheiro main, Item.c e h, e QUEUE.c e h caso seja preciso posso por mais partes do código. Vou meter apenas aquilo que acho que é preciso.
A função info imprime a informação (sumarizada) sobre todos os clientes activos do sistema: ref nche vche nchb vchb
ref = referencia
n= numero
ch= cheque
e= emitidos
b=beneneficiario
Erros
miguel@maa10Linux:~/iaed/proj2/codigo/versaofinal$ gcc -Wall -ansi -pedantic -o proj2 proj2.c Item.c QUEUE.c
proj2.c: In function 'veclientesativostree':
proj2.c:308:4: error: incompatible type for argument 1 of 'mostrainfocliente'
    mostrainfocliente(c);
    ^
proj2.c:300:6: note: expected 'Cliente' but argument is of type 'struct Cliente *'
 void mostrainfocliente(Cliente c){
  ^

Ficheiros

Item.c

[...]
typedef struct  {
    int valor;
    long int refe;
    long int refb;
    long int refc;

} Item;

[... ]

QUEUE.c

[...]
void QUEUEput(Item item) {
    if (head == NULL) {
        head = tail = NEW(item, head);
    }
    else {
        tail->next = NEW(item, tail->next);
        tail = tail->next;
    }
}

Item QUEUEget() {
    Item item = head->item;
    queuelink t = head->next;
    free(head);
    head = t;
    return item;
}

Item QUEUEfind(long refc, int (*cmp)(Item,long))
{
    queuelink t;
    Item item;
    item.refc = -1;

    for(t = head; t != NULL; t = t->next)
        if(cmp(t->item, refc) == 0)
            return t->item;
    return item;
}

Item QUEUEdelete(long refc, int (*cmp)(Item,long))
{
    queuelink t, prev;
    Item item;
    item.refc = -1;

    for(t = head, prev = NULL; t != NULL;
        prev = t, t = t->next) {
        if(cmp(t->item, refc) == 0) {
            if(t == head)
                head = t->next;
            else
                prev->next = t->next;
            if (t == tail) tail = prev;
            item = t->item;              /* fazer funcao */
            free(t);
            return item;
        }
    }
    return item;
}

Main.c

[...]
typedef struct cliente {
    long ref, nche, vche, nchb, vchb;
} Cliente;

typedef struct node {
    Cliente *item;
    struct node *l;
    struct node *r;
} *Link;

[...]
extern queuelink head, tail;
Link root;

int main()
{

    char* comando;
    comando = (char*)malloc(sizeof(char*)*MAXcomando);

    QUEUEinit();

    do { scanf("%s", comando);

        if(strcmp(comando, "cheque") == 0){
            comando_cheque();
    }
        else if (strcmp(comando, "processa") == 0){
            comando_processa();
    }
        else if (strcmp(comando, "processaR") == 0){
            comando_processaR();
    }
        else if (strcmp(comando, "infocheque") == 0){
            comando_infocheque();
    }
        else if (strcmp(comando, "infocliente") == 0){
            comando_infocliente();
    }
        else if (strcmp(comando, "info") == 0){
            comando_info();
    }
    }while (strcmp(comando, "sair") != 0);
        sair();

    return 0;
}

/* -----------------------------------FUNCOES------------------------------------*/

/* --------------- Clientes-arvore ------------------ */

Link insere(Link t, long ref, long valor)
{
    if (t == NULL) {
        t = (Link) malloc(sizeof(struct node));
        t->item = (Cliente*)malloc(sizeof(Cliente));
        t->item->ref = ref;
        t->item->nche = t->item->vche = t->item->nchb = t->item->vchb = 0;
        t->l = t->r = NULL;
    } else if (t->item->ref > ref) { t->l = insere(t->l, ref, valor);
        return t; }
      else if (t->item->ref < ref) { t->r = insere(t->r, ref, valor);
        return t; }

    if (valor > 0) {
        t->item->nche++;
        t->item->vche += valor;
    } else {
        t->item->nchb++;
        t->item->vchb -= valor;
    }
    return t;
}

Cliente *TREEget(Link t, long ref){
    if (t == NULL)
        return NULL;
    else if (t->item->ref > ref)
        return TREEget(t->l, ref);
    else if (t->item->ref < ref)
        return TREEget(t->r, ref);
    return t->item;
}

void TREEprint(Link t){
    if (t == NULL)
        return;
    TREEprint(t->l);
    if (t->item->nche != 0 || t->item->nchb != 0)
        printf("*%ld %ld %ld %ld %ld\n", t->item->ref, t->item->nche, t->item->vche, t->item->nchb, t->item->vchb);
    TREEprint(t->r);
}

void TREEinit(){
    root = NULL;
}

void print(Link t)
{
    if (t == NULL)
        return;
    print(t->l);
    printf("%ld", t->item->ref);
    print(t->r);
}

/* -------------------------------------Comandos--------------------------------------------*/

/* comando Cheque */

Item cheques;

void imprimeCheque(Item cheques) {
    printf("Valor:%d Emissor:%ld  Cheque nº:%ld Recetor:%ld\n", cheques.valor, cheques.refe, cheques.refc, cheques.refb);
}

void comando_cheque(){

    Item newcheque;
    scanf(" %d %ld %ld %ld", &newcheque.valor, &newcheque.refe, &newcheque.refb, &newcheque.refc);
    QUEUEput(newcheque);
    imprimeCheque(newcheque);
    /* actualiza clientes */
    root = insere(root, newcheque.refe, newcheque.valor);
    root = insere(root, newcheque.refb, -newcheque.valor);
}

/* processa */

void comando_processa() {
    Item item;
    Cliente *c;

    if (head == NULL)
        printf("Nothing to process\n");
    else {
        item = QUEUEget();

        /* actualizar clientes quando se tira da pool o cheque ha mais tempo emitido */
        c = TREEget(root, item.refe);
        c->nche--;
        c->vche -= item.valor;
        c = TREEget(root, item.refb);
        c->nchb--;
        c->vchb -= item.valor;

    }
}

/* processaR */

int compare(Item it, long ref) {
    return it.refc - ref; }

void comando_processaR() {
    long int ref;
    Item item;
    Cliente *c;

    scanf("%ld", &ref);
    item = QUEUEdelete(ref, compare);
    /* actualizar info */
        c = TREEget(root, item.refe);
        c->nche--;
        c->vche -= item.valor;
        c = TREEget(root, item.refb);
        c->nchb--;
        c->vchb -= item.valor;

}

/* infocheque */
void comando_infocheque(){
    long int ref;
    Item item;
    scanf("%ld", &ref);
    item = QUEUEfind(ref, compare);
    if (item.refc == -1)
        printf("Cheque %ld does not exist\n", ref);
    else
        printf("Cheque-info: %ld %d %ld --> %ld\n", item.refc, item.valor, item.refe, item.refb);

}

/* infocliente */
void comando_infocliente(){
    Cliente *c;
    long int ref;
    scanf("%ld", &ref);
    c = TREEget(root, ref);
    if (c == NULL || (c->nche == 0 && c->nchb == 0))
        printf("Cliente %ld does not exist\n", ref);
    else
        printf("Cliente-info: %ld %ld %ld %ld %ld\n", c->ref, c->nche, c->vche, c->nchb, c->vchb);

}

/* info */

int max(int a, int b)
{
    return (a > b)? a : b;
}
int clienteativo(Cliente *c){

    return ( (c->nche != 0) ||  (c->nchb != 0) );
}
int clienteativototal(Link t){

    if (t == NULL){
        return 0; }
    else  {
        if (clienteativo(t->item)){
            return clienteativototal(t->r)+ clienteativototal(t->l) + 1;}
        else {
            return clienteativototal(t-> r) + clienteativototal(t-> l);}
    }
}

void comando_info(){
    if (clienteativototal(root) == 0)
        printf("No active clients\n");
    else
        veclientesativostree(root);
}

void mostrainfocliente(Cliente c){
    printf("* %ld %ld %ld %ld %ld\n", c.ref, c.nche, c.vche, c.nchb, c.vchb);
}
void veclientesativostree (Link t){
    Cliente *c;
    if (t!=NULL)
        veclientesativostree(t-> l);
        if (clienteativo(c)){
            mostrainfocliente(c);
        }
    veclientesativostree(t-> r);
    }

Comment: Concordo com o @pmg, mas também acho que não seja este o problema. Aparentemente, a assinatura do comando difere dos parâmetros passados. Por favor, destaque as linhas 300 e 308 do arquivo `main.c`. Seu código é muito extenso, e estas linhas (bem como a assinatura do comando `mostrainfocliente`) são as regiões relacionadas ao problema.
Comment: Não ponhas as definições das `struct` no *main.c*. Mete-as no ficheiro .h e inclui esse ficheiro no *main.c* e em todos os outros .c que precisem dessas structs. Aparentemente o *main.c* tem `typedef struct cliente { ... } Cliente;` e outros ficheiros que precisem disso (o *proj2.c*) não sabem onde encontrar a definição.
Comment: Penso que não seja disso pois eu já consegui compilar e correr o programa mesmo com os ficheiros no main, eu nao coloquei nos posts mas o meu main e os outros ficheiros têm os includes correctos.
Penso já ter resolvido o problema mas entretanto surgiram outros, mas em breve coloco a minha soluçao
Comment: Eu sugiro que perca esse hábito de usar nomes como refe, ch, t etc. Se precisar de legenda pra saber o que é o quê, dá pra melhorar.
Answer: O problema é a passagem de parâmetros no comando veclientesativostree.
Você esta passando um Cliente* para a chamada mostrainfocliente, enquanto que a assinatura deste comando pede um Cliente.
Altere para:
void veclientesativostree (Link t){
    Cliente *c;
    if (t!=NULL)
        veclientesativostree(t-> l);
        if (clienteativo(c)){
            mostrainfocliente(*c); // necessário fazer a de-referência.
        }
    ...

Outra opção (melhor, na minha opinião), é alterar o comando mostrainfocliente para receber um const Cliente* ou const Cliente&. Assim, você evita a cópia da estrutura Cliente, tornando mais rápido u código.
Enfim, o resultado seria:
void mostrainfocliente(const Cliente &c){
    printf("* %ld %ld %ld %ld %ld\n", c.ref, c.nche, c.vche, c.nchb, c.vchb);
}

void veclientesativostree (Link t){
    Cliente *c;
    if (t!=NULL)
        veclientesativostree(t-> l);
        if (clienteativo(c)){
            mostrainfocliente(*c);
        }
    veclientesativostree(t-> r);
    }
    ...


Python to automatically select serial ports (for Arduino)

Question: Currently the python program must know which port a device (Arduino) is on before Python can communicate the device.
Problem: Whenever the device is plugged out and back in, its COM port changes, so the correct serial port must be given to Python again for it to find the device.
How can Python (using pySerial) automatically search for the correct serial port to use? Is it possible for python to correctly identify the device on a serial port as an Arduino?
Comment: If your problem is that the port changes in your computer as the USB device is disconnected and reconnected, then the answer may depend on the operating system. Are you using pySerial?
Comment: @user3735428 Yes I'm using pySerial. Hoping for a solution that works on Windows/Mac/Linux
Answer: Use the following code to see all the available serial ports:
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
for p in ports:
    print p

This gives me the following:
('COM4', 'Arduino Due Programming Port (COM4)', 'USB VID:PID=2341:003D SNR=75330303035351300230')
('COM11', 'RS-232 Port (COM11)', 'FTDIBUS\\VID_0856+PID_AC27+BBOPYNPPA\\0000')

To work out if it's an Arduino you could do something like:
    if "Arduino" in p.description:
        print "This is an Arduino!"

Comment: `p[1]` is better spelt `p.description`
Comment: This works for Linux as well, even though the ports have different names and "Arduino" is not in `p.description`.  Instead, `p.manufacturer` contains "Arduino" and `p.serial_number` tells me which is which :-)
Comment: This also works if you're plugged into the Native USB port on the Arduino Due. I haven't tested it on any other Arduino's.
Comment: If you check p.hwid for "VID:PID=2341:0043", that is an arduino uno, and that will work with the knockoffs as well. You would need to use a different PID (just scan your ports like in the post to find the correct one).
Comment: You can also use `serial.tools.list_ports.grep('Arduino')` to filter out unwanted devices. You can search by string or regular expression https://pyserial.readthedocs.io/en/latest/tools.html#serial.tools.list_ports.grep
Answer: Using serial.tools.list_ports.comports, we can find and connect to an arduino with:
import warnings
import serial
import serial.tools.list_ports

arduino_ports = [
    p.device
    for p in serial.tools.list_ports.comports()
    if 'Arduino' in p.description  # may need tweaking to match new arduinos
]
if not arduino_ports:
    raise IOError("No Arduino found")
if len(arduino_ports) > 1:
    warnings.warn('Multiple Arduinos found - using the first')

ser = serial.Serial(arduino_ports[0])

If you know you're looking for exactly the same arduino each time, you can filter on p.serial_number instead
import serial.tools.list_ports

def find_arduino(serial_number):
    for pinfo in serial.tools.list_ports.comports():
        if pinfo.serial_number == serial_number:
            return serial.Serial(pinfo.device)
    raise IOError("Could not find an arduino - is it plugged in?")

ser = find_arduino(serial_number='85430353531351B09121')

Comment: Works very nice, but only for original Arduino. Non-original Arduinos will report differently, e.g. "Generic CDC"... ultimately the best solution would be to list all possible USB devices and then allow a user to pick one using a runtime flag.
Comment: @dust: Right, but for the common case where you're bouncing one piece of hardware between multiple USB ports and computers, this technique is most convenient. If you're looking to detect previously-unseen arduino-like devices, you're going to have a harder time, and forcing the user to choose as you mention is probably the best path
Comment: Is it possible to program the description given from the Arduino? Then each python will find and connect to the exact Arduino it needs.
Answer: """
Written on a Windows 10 Computer, Python 2.7.9 Version.

This program automatically detects and lists ports.  If no ports are found, it simply shells out.  In the printout below "list(serial.tools.list_ports.comports())" finds two ports and the program lists them out - a listout shown below:

     COM5 - USB-SERIAL CH340 (COM5)
     Found Arduino Uno on COM5
     COM4 - Microsoft USB GPS Port (COM4)

As each port is found, "CH340," (the name of the Adruino Uno) is searched for in the listed port with the "while int1 < 9:" loop.  The first "If" statement looks for "CH340" and when found the integer value "int1" will be the same as the com port #. With a concatination,  the operation "str1 = "COM" + str2" gives the com port name of the Adruino, eg. "COM5."  The next "IF" statement looks for both "CH340" AND str1, ("COM5") in the above case.  The statement "Found Arduino Uno on COM5" prints out, and "str1" is used in setting up the com port:

ser = serial.Serial(str1, 9600, timeout=10)

This program goes on to open the com port and prints data from the Adruino.

The modules "serial, sys, time, serial.tools.list_ports" must all be imported.

Written by Joseph F. Mack 01/29/2016.  "A BIG Thank you" to all the individuals whose programs I "borrowed" from that are available in the many forums for Python and PYGame users!
"""

import serial
import sys
import time
import serial.tools.list_ports

serPort = ""
int1 = 0
str1 = ""
str2 = ""

# Find Live Ports
ports = list(serial.tools.list_ports.comports())
for p in ports:
   print p # This causes each port's information to be printed out.
           # To search this p data, use p[1].

   while int1 < 9:   # Loop checks "COM0" to "COM8" for Adruino Port Info.

      if "CH340" in p[1]:  # Looks for "CH340" in P[1].
            str2 = str(int1) # Converts an Integer to a String, allowing:
            str1 = "COM" + str2 # add the strings together.

      if "CH340" in p[1] and str1 in p[1]: # Looks for "CH340" and "COM#"
         print "Found Arduino Uno on " + str1
         int1 = 9 # Causes loop to end.

      if int1 == 8:
         print "UNO not found!"
         sys.exit() # Terminates Script.

      int1 = int1 + 1

time.sleep(5)  # Gives user 5 seconds to view Port information -- can be   changed/removed.

# Set Port
ser = serial.Serial(str1, 9600, timeout=10) # Put in your speed and timeout value.

# This begins the opening and printout of data from the Adruino.

ser.close()  # In case the port is already open this closes it.
ser.open()   # Reopen the port.

ser.flushInput()
ser.flushOutput()

int1 = 0
str1 = ""
str2 = ""

while int1==0:

   if "\n" not in str1:        # concatinates string on one line till a line feed "\n"
      str2 = ser.readline()    # is found, then prints the line.
      str1 += str2
   print(str1)
   str1=""
   time.sleep(.1)

print 'serial closed'
ser.close()

Comment: This is terribly-written code. `int` is not a sensible variable name, and 8 and 9 are deeply magic numbers
Comment: This code won't work for genuine Arduinos. Genuine Arduinos use FTDI USB-Serial bridges whereas the CH340/CH341 serial ports are Jiangsu Qinheng chips and are found only on cheap Chinese Arduino "clones."
Comment: I assume this program is run on the computer plugged into the Arduino. Is that right? What extension is used to save this file?
Answer: Try this code (only for windows users. MAC user can withdraw idea from this concept)
import serial
import time
list=['COM1','COM2','COM3','COM4','COM5','COM6','COM7','COM8','COM9','COM10','COM11','COM12','COM13','COM14','COM15','COM16','COM17','COM18',]

COM1='COM1'
COM2='COM2'
COM3='COM3'
COM4='COM4'
COM5='COM5'
COM6='COM6'
COM7='COM7'
COM8='COM8'
COM9='COM9'
COM10='COM10'
COM11='COM11'
COM12='COM12'
COM13='COM13'
COM14='COM14'
COM15='COM15'
COM16='COM16'
COM17='COM17'
COM18='COM18'
COM19='COM19'
time.sleep(1)
ser = serial.Serial()

ser.baudrate = 9600

i=1

while True:
    time.sleep(.2)
    print(i)
    ser.port = list[i]
    try:

        ser.open()
        if ser.isOpen()==True:
            print('connected')
            #print('arduino is on COMPORT'.join(i))
            break
        break

    except:
        print('waiting')
        i=i+1
        if i==18:
            print('Kindly remove usb cable and try again')
            break

print('here we go')
while True:
    print(ser.readline())


PHP preg_replace alternative

Question: We're currently getting a preg_replace error message on our site due to deprecation.
Our code is as follows:
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data);

Any suggestions on how this can be replaced with non-deprecated code?
Answer: preg_ is not deprecated. It is just /e (as of PHP 5.5):

The /e modifier is deprecated. Use preg_replace_callback() instead.
  See the PREG_REPLACE_EVAL documentation for additional information
  about security risks.

and as preg_replace_callback() is almost identical to preg_replace() with exception that it uses callback instead of replacement, update of your code should be quick homework.
Answer: You're using the modifiers s and e. Copied directly from Deprecated feature sin PHP 5.5.x:

The preg_replace() /e modifier is now deprecated. Instead, use the preg_replace_callback() function.
Answer: In this case, I found this "callback_function" that works fine:
$fixed_text = preg_replace_callback ( '!s:(\d+):"(.*?)";!',
function($m) {
       return ($m[1] == strlen($m[2])) ? $m[0] : 's:' . strlen($m[2]) . ':"' . $m[2] . '";';
},
$text);

PHP preg_replace alternative


Is there a technical term for sad songs with happy lyrics and vice versa?

Question: I'm talking about things like the Pogues "Fairy Tale of New York", an upbeat song with bitter lyrics like

Happy Christmas your arse / I pray God it's our last

Is there a technical term or collective name for songs where the emotion indicated by the music is at odds with the emotion indicated by the lyrics?
Comment: This might be better over on english.stackexchange.com Flagged for migration
Comment: I think this is on-topic but you would probably do well to ask it on English.  If you do, just let me know and we'll close this version.
Comment: Although it is English language, this is very specific to musical terms, and it is likely to be more experts on this here on Music than on English.
Answer: Lyrical dissonance or agathocacological
Comment: Good answer.  A minor technical point on spelling - i.e., agathokakological .  I only know this because I had to look up the definition.
Answer: There may be a term specific to the realm of music that I'm not aware of. Barring that, the first term that comes to mind is incongruous. It refers to a lack of consistency or harmony.
You could use the same word to describe a man wearing sweat pants to a black tie affair, or the sight of chicken fingers on a fancy French menu.
Comment: Les doigts de poulet!
Answer: I think ironic would be appropriate; perhaps qualified "musically ironic"?
In standard music terminology, perhaps "scherzando" (It. in a jesting manner)?


Using Concat Operator ( || ) the Integer Part of is not shown for floating numbers

Question: When I am writing a SELECT query in Oracle using concat || operator  to concatenate a decimal number and a string. Then for values that have integer part as zero is not shown.
But when I am only selecting Number the Integer part is shown.
My SQL Query Structure :-
SELECT
NUMBER_VAL ||
STRING_VAL
FROM MY_TABLE;

for E.g (selecting only Number):-
SELECT 0.1 FROM DUAL;

I am getting Result: 0.01
E.g (Selecting Number and String Concatenated) :-
SELECT 0.01 || 'ABCD' FROM DUAL;

I am Getting Result: .01ABCD
Desired Result: 0.01ABCD
Can anyone help me how can I achieve the desired result.

This is in Addition to Rics Answer .
The Data type of NUMBER_VAL was NUMBER(9,4).
And that's why I had to Use the Format '99990.9999'
Comment: Try this `SELECT '0.01' || 'ABCD' FROM DUAL ;`
Comment: @PRDP I mentioned in the SQL Structure that the Number is a column from a table and the Example was to just make the Question more clear.
Comment: Then `cast` the column to `varchar`
Comment: @Prdp - How is `cast` going to help with the OP's problem? The correct answer has already been given and it has nothing to do with `cast`.
Comment: @mathguy - TBH am not a Oracle guy. Just giving my suggestion that is the reason I didn't post answer
Comment: @Prdp - no problem with that in general, but you offered your suggestion after the correct answer had already been posted. If you are not an Oracle guy, trust the Oracle guys and gals (there are a few) to answer Oracle questions!
Comment: And more generally don't rely on implicit type conversion -- it will trip you up eventually.
Answer: Use to_char function and the appropriate number format:
SELECT
to_char(NUMBER_VAL,'0.99') ||
STRING_VAL
FROM MY_TABLE;

Comment: To format your code, select it and press [ctrl]-k or the `{}` symbol in the editing bar. I did that for you here, but remember for the future. Cheers!
Answer: You can specify format when converting to string, such as:
SELECT TO_CHAR(0.01, '0.00') || 'ABCD' FROM DUAL;


If we know the prime factors of an integer, how much do we know about the prime factors of its successor?

Question: Given an integer $n$, how much do we know and how much can we know about the prime factors of $n+1$ without actually factoring it?
An example from the comments: If $n = 3^{4k+2}$, then $n+1$ is divisible by 5. Is there a general theory describing all we can know about the factors of $n+1$ without factoring it? Or theories describing this behavior for a nontrivial subset of the integers?
Comment: In the example you gave, we know that $n + 1$ has *no* chance of being divisible by 3 or 7.    In general, $n$ and $n + 1$ have no prime factors in common.  I don't think much more is known but I am not expert in this area.
Comment: Wait a moment... "*has a 1/2 chance of being divisible by 3*"?  Why do you say that $n+1$ is not even but you think there is still a chance of it being or not being divisible by $3$?  Perhaps you mean to talk about "*has a chance of being divisible by $p$*" where $p$ is *not* a factor of your number.
Comment: Now... another nitpick, "*given a random integer $n$*" This is ambiguous and imprecise, and the naive interpretation here is impossible.  You can not have a uniform random distribution over a countably infinite set.  So then, what distribution *do* we have since it can not be uniformly random?  If it is a distribution such that we only ever pick numbers that are $1$ less than a multiple of $5$, then I can say with 100% certainty that the successor is a multiple of $5$...
Comment: Your inferences only require knowing which prime $p$ divide $n$; their orders as factors are unnecessary. What you're saying is, for $p\in\Bbb P$, the probability that $p|n+1$ is $0$ given $p|n$, or $1/(p-1)$ given $p\nmid n$. This formulation lets us sidestep the question of what _random_ means.
Comment: In general, the only thing we could say about the prime factors of $n+1$ is that none of them are also prime factors of $n$. Given any two disjoint sets of primes $P$ and $Q$, there is always a number $n$ for which $n$ is divisible by the primes in $P$ (and possibly more) and $n+1$ is divisible by the primes in $Q$ (and possibly more) by the Chinese Remainder Theorem.
Comment: One thing to think about: if we understood this well enough, the famous Collatz conjecture would be solved. The Collatz conjecture comes down to: what happens to the number of 2's in the prime factorization of an odd number after we add a factor of 3 and then increment? This is a fairly restricted version of your question and even this is famously elusive.
Comment: Related: https://math.stackexchange.com/questions/2694/what-is-the-importance-of-the-collatz-conjecture
Comment: Sorry, I got utterly confused. I meant to make that observation about the primes not present in the factorization.
Comment: @JMoravitz I'm not sure. The spirit of it is that I would like for the answer to say something about all integers. What would be a suitable way to characterize $n$ then?
Comment: Now... to try to make some sense of what one might have hoped for from a "uniform distribution over the natural numbers"... we could talk about the *relative density* of certain classes of numbers... where here we can say things such as "The relative density of numbers divisible by $5$ in the integers is $\frac{1}{5}$" by considering $\lim\limits_{n\to\infty}\dfrac{|\{k~:~1\leq k\leq n,~5\mid k\}|}{|\{k~:~1\leq k\leq n\}|}$
Comment: You can say more, if you're willing to look at the prime factors of $n$ modulo other primes; for instance, with your example $n$, I can see there's a probability of $1$ that $n+1$ is divisible by $5$. But I'm not sure if this is what you're looking for (I guess it's more about the definition of random being used, per your other discussion)
Comment: @ChrisLewis I think that's the sort of thing I want to ask, but I'm hesitant about saying something like "given the prime factors of $n$ modulo any prime..." since it seems like it would lead to trivial answers. Is this the case?
Comment: Now, I don't think a probabilistic approach is appropriate here.  We *can* learn things about successors of numbers from their factorization if we work hard enough.  For instance, I know that $3^{4k+2}+1$ must be a multiple of $5$ without factoring from modular arithmetic.  I also know that the number in your example which is 7 digits in length, its successor is not divisible by any prime that is, say, 10 digits in length, and further that it can not be divisible by multiple primes that are 4 digits in length, so the events you consider are not independent.
Comment: @JMoravitz I agree that I don't particularly want to ask about probabilistic results. I just felt like I had to include it in the question because it was the only thing I could think about and the question could have been downvoted otherwise :( I'll edit with your example.
Comment: We can certainly say a lot of cases like what you have written - for example of one variant, $3^{a_1}13^{a_2}23^{a_3}+1$ is divisible by $5$ if $a_1+a_2+a_3\equiv 2\pmod 4.$ But these don't generalize to talking about general $n,$ not general primes.
Comment: In general, if we know the primes $p_1,\dots,p_k$ are the prime divisors of $n,$ it is hard to exclude any prime divisors of $n+1$ other than those primes. If there is a prime $q\equiv 3\pmod 4$ and each $p_i$ is a square modulo $q,$ then $q$ cannot be a prime factor of $q+1.$ So, for example, $q=7$ then if all the prime divisors of $n$ are $\equiv1,2,4\pmod7,$ then $n+1$ cannot be divisible by $7$. So, for example, $2^a11^b29^c+1$ is never divisible by $7.$
Comment: But otherwise, given $p_1,p_2,\dots,p_k,q$ distinct primes, and and some $p_i$ is not a square, modulo $q,$ we can find an $n$ which has $p_1,\dots,p_k$ as the unique prime factors such that $n+1$ is divisible by $q.$
Comment: In general, if $\frac{q-1}{2^r}$ is odd, and each of $p_1,\dots,p_k$ is a $2^r$th power, modulo $q,$ there is no $n$ with $n+1$ divisible by $q.$ For example, $q=13$ then $r=2$ and you need $p_i\equiv 1,3, 9.$ Then there is no $n=3^a53^b61^c$ such that $n+1$ is divisible by $13.$
Comment: The short answer is : nothing. We can only rule out the prime factors of $n$ for $n-1$ and $n+1$. If there would be any relation allowing us to factor the neighbours , we could efficiently factor all numbers , in particular the fermat numbers , we would even have an immediate primality test for , say , the $33$ rd fermat number.
Answer: There is not much known in general.
Aside from the obvious - the prime factors of $n$ are distinct from the prime factors of $n+1$ - we cannot say much.
We can exclude other prime factors of $n+1$ only in a few cases.
If $p_1,\dots,p_k,q$ are distinct primes, and $r=\nu_2(q-1)$ is the highest integer such that $2^r\mid q-1,$ then we have the result:

There does not exist $n$ with the unique prime factors $p_1,\dots,p_k$ with $n+1$ divisible by $q$ iff, for each $i,$ we can solve the congruence $x_i^{2^r}\equiv p_i\pmod q.$

If, for example, there is no $x_1,$ then $p_1$ has an even multiplicative order, $2m,$ modulo $q,$ and $n=p_1^mp_2^{q-1}p_3^{q-1}\cdots p_k^{q-1}$ has $n+1$ divisible by $q.$
On the other hand, if there is an $x_i$ for each $i,$ then $n$ will always be a $2^r$th power modulo $q,$ and $-1$ is never a $2^r$th power modulo $q.$
For example, if $q=13,$ $r=2,$ and we find the fourth powers modulo $13$ are $1,3,9.$ So if all the prime factors of $n$ are $\equiv1,3,9\pmod{13},$ then $13$ cannot be a factor of $n+1.$ But if any prime factor is not one of these, then we can find an $n.$

The abc Conjecture would say that, for any $\alpha<1,$ there are at most finitely many $n$ such that the product of the distinct prime factors of $n(n+1)$ is less than $(n+1)^\alpha.$ But that is still only a conjecture.
This obviously is not true for $\alpha=1.$ For example, $n=2^{6k}-1$ is divisible by $9,$ so the product of the prime factors of $n$ and $n+1$ is at most $\frac23n<n+1.$
Answer: One special case is when $n+1$ is prime, and then knowing the prime factorization of $n$ can be helpful in proving that $n+1$ is prime.
Suppose for each prime factor $p_i$ of $n$ we can find $b_i$ such that:
$$\begin{align*}
b_i^n &\equiv 1 \bmod (n+1), \text{ but }
\\b_i^{n/p_i} &\not\equiv 1 \bmod (n+1)
\end{align*}$$
Then $n+1$ is prime, because it follows that $\varphi(n+1) = n$, i.e. all positive integers less than $n+1$ are relatively prime to $n+1$.
An important improvement on this when only a partial factorization of $n$ is known is due to H.C. Pocklington (1914).  Bressoud's Factorization and Primality Testing, Chapter 9 (Primitive Roots and a Test for Primality) gives details and references.


400 Bad Request Error while getting full Linkedin Profile via Spring Social

Question: I am using Spring Social to sign-in users through LinkedIn. When I am accessing LinkedInUserProfile it is working fine but when I try to access full profile I get below exception. So line 2 in below code works fine, but line 3 throws the exception
LinkedIn linkedinApi = (LinkedIn) connection.getApi();
LinkedInProfile linkedinProfile = linkedinApi.profileOperations().getUserProfile();
LinkedInProfileFull linkedinProfileFull = linkedinApi.profileOperations().getUserProfileFull();

The eception is
[ERROR] 2015-03-08 08:55:06.124 [http-nio-8443-exec-2] ProviderSignInController - Exception while completing OAuth 2 connection:
org.springframework.social.UncategorizedApiException:
    at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleUncategorizedError(LinkedInErrorHandler.java:62) ~[spring-social-linkedin-1.0.1.RELEASE.jar:1.0.1.RELEASE]
    at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:55) ~[spring-social-linkedin-1.0.1.RELEASE.jar:1.0.1.RELEASE]
    at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:588) ~[spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:546) ~[spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:517) ~[spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:255) ~[spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.social.linkedin.api.impl.ProfileTemplate.getProfileFullById(ProfileTemplate.java:127) ~[spring-social-linkedin-1.0.1.RELEASE.jar:1.0.1.RELEASE]
    at org.springframework.social.linkedin.api.impl.ProfileTemplate.getProfileFullById(ProfileTemplate.java:104) ~[spring-social-linkedin-1.0.1.RELEASE.jar:1.0.1.RELEASE]
    at com.icanrecruit.social.security.AccountConnectionSignUp.execute(AccountConnectionSignUp.java:39) ~[AccountConnectionSignUp.class:?]
    at org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository.findUserIdsWithConnection(JdbcUsersConnectionRepository.java:86) ~[spring-social-core-1.1.0.RELEASE.jar:1.1.0.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_65]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_65]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_65]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at com.sun.proxy.$Proxy29.findUserIdsWithConnection(Unknown Source) ~[?:?]
    at org.springframework.social.connect.web.ProviderSignInController.handleSignIn(ProviderSignInController.java:260) ~[spring-social-web-1.1.0.RELEASE.jar:1.1.0.RELEASE]
    at org.springframework.social.connect.web.ProviderSignInController.oauth2Callback(ProviderSignInController.java:217) [spring-social-web-1.1.0.RELEASE.jar:1.1.0.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_65]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_65]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_65]
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214) [spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) [servlet-api.jar:?]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) [spring-webmvc-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:?]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [catalina.jar:8.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.17]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.17]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at com.icanrecruit.security.api.TokenAuthenticationFilter.doFilter(TokenAuthenticationFilter.java:53) [TokenAuthenticationFilter.class:?]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) [spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) [spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) [spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.17]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:8.0.17]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.17]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613) [catalina.jar:8.0.17]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [catalina.jar:8.0.17]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.17]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) [catalina.jar:8.0.17]
    at org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:504) [catalina.jar:8.0.17]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.17]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516) [catalina.jar:8.0.17]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086) [tomcat-coyote.jar:8.0.17]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659) [tomcat-coyote.jar:8.0.17]
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) [tomcat-coyote.jar:8.0.17]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558) [tomcat-coyote.jar:8.0.17]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515) [tomcat-coyote.jar:8.0.17]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_65]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_65]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.17]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_65]
Caused by: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.0.1.RELEASE.jar:4.0.1.RELEASE]
    at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleUncategorizedError(LinkedInErrorHandler.java:60) ~[spring-social-linkedin-1.0.1.RELEASE.jar:1.0.1.RELEASE]
    ... 88 more

When I debug, the log is as follows, so there is a problem with "ı" character, hence it can be related with localization. Anyone who has an idea what is going on here?
[DEBUG] 2015-03-08 08:55:05.971 [http-nio-8443-exec-2] RestTemplate - Created GET request for "https://api.linkedin.com/v1/people/id=vOp_9S25si:(ıd,fırst-name,last-name,headlıne,locatıon,ındustry,dıstance,relatıon-to-vıewer,current-share,num-connectıons,num-connectıons-capped,summary,specıaltıes,proposal-comments,assocıatıons,honors,ınterests,posıtıons,publıcatıons,patents,languages,skılls,certıfıcatıons,educatıons,three-current-posıtıons,three-past-posıtıons,num-recommenders,recommendatıons-receıved,phone-numbers,ım-accounts,twıtter-accounts,date-of-bırth,maın-address,member-url-resources,pıcture-url,site-standard-profile-request:(url),api-public-profile-request:(url),site-public-profile-request:(url),apı-standard-profıle-request,publıc-profıle-url,emaıl-address)?format=json"

Answer: For the ones who face something similar, from the exception I tracked this down to the code of ProfileTemplate.java
https://github.com/spring-projects/spring-social-linkedin/blob/master/spring-social-linkedin/src/main/java/org/springframework/social/linkedin/api/impl/ProfileTemplate.java
which uses ProfileField.values()
public enum ProfileField {
    ID,
    FIRST_NAME,
    LAST_NAME,
    HEADLINE,
    LOCATION,
    INDUSTRY,
    DISTANCE,
    RELATION_TO_VIEWER,
    CURRENT_SHARE,
    CONNECTIONS,
    NUM_CONNECTIONS,
    NUM_CONNECTIONS_CAPPED,
    SUMMARY,
    SPECIALTIES,
    PROPOSAL_COMMENTS,
    ASSOCIATIONS,
    HONORS,
    INTERESTS,
    POSITIONS,
    PUBLICATIONS,
    PATENTS,
    LANGUAGES,
    SKILLS,
    CERTIFICATIONS,
    EDUCATIONS,
    THREE_CURRENT_POSITIONS,
    THREE_PAST_POSITIONS,
    NUM_RECOMMENDERS,
    RECOMMENDATIONS_RECEIVED,
    PHONE_NUMBERS,
    IM_ACCOUNTS,
    TWITTER_ACCOUNTS,
    DATE_OF_BIRTH,
    MAIN_ADDRESS,
    MEMBER_URL_RESOURCES,
    PICTURE_URL,
    SITE_STANDARD_PROFILE_REQUEST_URL,
    API_PUBLIC_PROFILE_REQUEST_URL,
    SITE_PUBLIC_PROFILE_REQUEST_URL,
    API_STANDARD_PROFILE_REQUEST,
    PUBLIC_PROFILE_URL,
    EMAIL_ADDRESS
    ;

    public String toString() {
        switch (this) {
        case SITE_STANDARD_PROFILE_REQUEST_URL:
            return "site-standard-profile-request:(url)";
        case API_PUBLIC_PROFILE_REQUEST_URL:
            return "api-public-profile-request:(url)";
        case SITE_PUBLIC_PROFILE_REQUEST_URL:
            return "site-public-profile-request:(url)";
        default:
            return this.name().toLowerCase().replace('_', '-');
        }
    }

}

which are all in capital letters, and when they are turned to lowercase it uses system locale, which was not set to "en", resulting in invalid request. When I changed system local the problem was solved. For now I can use "en" locale, if I need to change it later on, this needs to be solved differently.


Extension of a triangulation of the sphere to a triangulation of the ball

Question: $S$ is the $3$-dimensional sphere (in $\mathbb R^3$) and $T$ is a triangulation of $S$. It is known that $T$ can be extended to a triangulation of the ball by adding points inside the ball (one point at each step), and connecting each to at most $6$ previous points.
I need to give an example of a tringulation of the sphere for which adding points connected to $5$ previous points does not yield an extension to a triangulation of the ball.
I can not think of such a triangulation, so any help would be appreciated.
Comment: Is a "triangulation of the ball" a set $K$ of (non-overlapping) tetrahedrons, some subset $L$ of which may have three vertices on the sphere,  such that $K$  covers the entire ball other than volumes  that are bounded by a face in $L$ and the corresponding spherical triangle on the surface of the sphere?
Comment: Yes, that is the definition.
Answer: An answer is a triangluation $T$ formed by the vertices of a regular icosahedron inscribed in the sphere.
Since every vertex in $T$ has five emerging faces, if you add an interior point connected to fewer than six vertices, you make no progress in reducing the minimum number of additional points needed to complete the triangularization.


module_load_include not working

Question: I've been looking on several sites trying to figure this out, but no dice yet.
I have a module, 'spower'. I need to include several php files inside the polygon folder (spower/polygon/*.php). In the spower.module file, I've included the line:
module_load_include('php', 'spower', 'polygon/polygonBase');
However, when I run the module, I get the error Call to undefined function PolygonBase, so obviously, something's not loading right.
Answer: Assuming you want to load
sites/all/modules/custom/spower/polygon/polygonBase.php

then
module_load_include('php', 'spower', 'polygon/polygonBase');

should work fine.

Make sure the file polygonBase.php is readable by the webserver user.
Make sure module_load_include is added for processing prior to using functions in that file.
Comment: It was a permission problem :$ Thanks for the help.
Answer: In order to debug whether module_load_include() is working or not, you can check the return value using code as
$file_path = module_load_include('php', 'spower', 'polygon/polygonBase');

if ($file_path === FALSE) {
  dpm('Failed to include: ' . $filename);
}
else {
  dpm('Successfully included: ' . $file_path);
}

Comment: I'm getting the message `failed to include: filename`;

module_load_include not working


Does having too many cck fields negatively affect site speed and performance?

Question: I building a site that could potentially utilize 50 different content types. The most of the content types have more than 40 CCK fields, including multiple field_collections entity_reference.
How can i take care about performance of site Specially for CCK fields level ?
Answer: Yes. The more fields you have, the more load you should expect on your database server; that's a given.
What it means in real terms depends on your hardware, configuration and usage - you'll need to benchmark your site in that actual environment to come to any meaningful conclusion. If you get one request a day, for example, your pages are cached, and you have a brand new shiny server, then you probably won't need to think about changing anything.
If you get thousands of requests per second, all your pages are non-cacheable, and your server isn't great, then you might have to think about re-structuring that data so it's more performant (e.g. creating custom field types to combine data from multiple other field types into a single table).
In short, there's no general answer to what you're asking. You need to see what problems your application develops under load, if any, and deal with them then. Premature optimisation is rarely a good idea.
All of that said, Drupal's main defence against this kind of thing is caching. There's a great post here: How do you improve Drupal performance?
Answer: This is the sort of question that's almost impossible to answer without benchmarking on your actual hardware. Sure, the number of content types and CCK fields will affect performance, but if most of the activity is browsing by logged out visitors, the page content can be cached, so displaying the pages should put relatively little strain on your server. On the other hand, if they are highly dynamic pages constantly being updated my multiple users, you could find your server is quickly dragged to its knees.


Using nested boost::binds

Question:
Compiler: g++ 4.4.3
Boost...: 1.49.0
OS......: Ubuntu

Note: It's been 15 years since I seriously used C++, so I'm relearning and learning new things as I also try to learn Boost.
Given the following code:
1.      class Beta {
2.      public:
3.          std::string name();
4.      }
5.
6.      class Alpha {
7.      public:
8.          Beta m_beta;
9.      }
10.
11.     Alpha one;

For various reasons, I wanted to use boost:bind to achieve
the same result as if "one.m_beta.name()" were called.  I
thought the following would do it:
12.     boost::function<std::string(Alpha)>
13.         b = boost::bind(
14.             &Beta::name,
15.             boost::bind(&Alpha::m_beta, _1)
16.         );
17.     cout << "NAME = " << b(one) << "\n";

But when I compile (g++ 4.4.3 on Ubuntu) I get the following
error:
error: invalid conversion from 'const Beta*' to 'Beta*'
After looking at the actual type definition resulting from
lines 13-16, it looks like line 15 is becoming 'const Beta*', but
the bind wrapping it expects 'Beta*'.
However, this DOES work:
30.     boost::function<std::string(Beta)>
31.         p1 = boost::bind(&Beta::name,_1);
32.     boost::function<Beta(Alpha)>
33.         p2 = boost::bind(&Alpha::m_beta,_1);
34.     std::cout << "NAME = " << p1(p2(one)) << "\n";

But I really don't want to carry around a lot of intermediate variables.
It did make me think that there must be some way to get the
first version to work as well.  I've already tried the
following as replacements for line 15, but they all give out
one or another error at compilation time too.
50. (boost::function<Beta&(Alpha)>)(boost::bind(&Alpha::m_beta,_1))
51. (boost::function<Beta(Alpha)>)(boost::bind(&Alpha::m_beta,_1))
52. (boost::function<Beta*(Alpha)>)(boost::bind(&Alpha::m_beta,_1))
53. boost::protect(boost::bind(&Alpha::m_beta,_1))
54. boost::ref(boost::bind(&Alpha::m_beta,_1))
55. const_cast<Beta*>(boost::bind(&Alpha::m_beta,_1))
56. const_cast<boost::function<Beta(Alpha) > >(boost::bind(&Alpha::m_beta,_1))
57. const_cast<boost::function<Beta*(Alpha) > >(boost::bind(&Alpha::m_beta,_1))

What am I missing?
Comment: I'd almost guarantee that the actual issue is a (symptom of the) failure of perfect fowarding in C++99/03. Somewhere a `Beta` is being accepted as a `Beta const&`.  You might try compiling with --std=c++0x and using `std::bind`; that might have been implemented to do perfect forwarding.
Comment: Well one thing to note is that bind is now standard (in ``). There's no need to use Boost anymore, since even GCC 4.4 supports it.
Comment: Note that for (what I assume to be) your synthetic example it would very likely be customary to declare `Beta::name` as `std::string name() const;`. This would in all likeliness avoid the error (although the question still is very relevant in spirit).
Comment: Many thanks to all of you! Twansbury's answer does exactly what I needed, but I'm going to give the other suggestions a try as well.
Comment: @LucDanton Unfortunately, Alpha and Beta are stand-ins for two classes in a third party library that while I have source, I'm not supposed to modify.
Answer: Explicitly specify a Beta& return type for the nested boost::bind:
boost::function< std::string( Alpha ) > b =
  boost::bind(
    &Beta::name,
    boost::bind< Beta& >( &Alpha::m_beta, _1 ) );

The reason the const Beta* and Beta* conversion errors are occurring is the result of boost::bind having the same behavior as boost::mem_fn, which states:

mem_fn also supports pointers to data members by treating them as functions taking no arguments and returning a (const) reference to the member.`

Thus, the nested-bind is returning a const Beta&, which is an invalid instance to invoke the non-const name() member function on Beta.
Comment: With Boost 1.50 there are also some pains when passing the result of `boost::bind` to `boost::function`. If the signature of `b` is changed to `std::string(Alpha&)` this compiles however.
Comment: Finally, `std::bind` (even in tandem with `std::function`) does not appear to exhibit this problem. (Which is conforming to the specification TTBMK.)
Comment: Many thanks to all of you!  Twansbury's answer does exactly what I needed, but I'm going to give the other suggestions a try as well.

Using nested boost::binds


In a multinomial naive Bayes classifier, is the feature vector always a histogram?

Question: In the Wikipedia definition, the feature vector is defined as a histogram, as well as in this popular and well-done YouTube video.
However, if the features are words, then the variable is nominal and, therefore, the distribution cannot be estimated by a histogram (rather, it would be a bar chart).
Are these two sources wrong?
Edit: I've added the time code for the video
Comment: So your initial answer was correct: calling it a histogram is an abuse of terminology. I was doubting because I saw this in two "reliable" sources.
Comment: Sorry, but I see the opposite in the article:
"A feature vector x = ( x1, … , xn) is then a histogram, with xi counting the number of times event i was observed in a particular instance."
So it is n features for one instance.
Comment: my bad (I guess I should switch off!) you are right $x$ is a barplot.
Comment: sure, I re-updated the answer. I got confused by $n$, which we typically reserve for the sample size.
Answer: As ${\bf x} = (x_1,\ldots,x_n)$  and $x_i$ represent the number of times the instance/word $i$ realizes, then the vector $x$ is a vector of counts.
Thus, yes, ${\bf x}$ would be a barplot and not a histogram.
Comment: What does "However, no Wikipedia is correct" mean?
Comment: @jbowman: it was a typo of course. corrected.


When do handlers for cancelled boost::asio handlers get to run?

Question: The boost docs say that cancelled async connect, send and receive finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error.
I would like to find out if the cancelled handler gets to run (and see the operation_aborted error) before other (non-cancelled, and newly scheduled) completion handlers run.
Here is the timeline that concerns me:
acceptHandler and readHandler are running on the same event loop and the same thread.

time t0 - readHandler is running on oldConnectionSocket
time t1 - acceptHandler runs
time t2 - acceptHandler calls oldConnectionSocket.cancel
time t3 - acceptHandler closes oldConnectionSocket
time t4 - acceptHandler calls newConnectionSocket.async_read(...readHandler...)
time t5 - readHandler is called (from which context?)

Is it possible at t5 for readHandler to be called in the newConnectionSocket context before it is called with the operation_aborted error in the oldConnectionSocket context?
Answer: Cancelled operations will immediately post their handlers for deferred invocation.  However, the io_service makes no guarantees on the invocation order of handlers.  Thus, the io_service could choose to invoke the ReadHandlers in either order.  Currently, only a strand specifies guaranteed ordering under certain conditions.
Within a completion handler, if the goal is to know which I/O object was associated with the operation, then consider constructing the completion handler so that it has an explicit handle to the I/O object.  This is often accomplished using any of the following:

a custom functor
std::bind() or boost::bind()
a C++11 lambda

One common idiom is to have the I/O object be managed by a single class that inherits from boost::enable_shared_from_this<>.  When a class inherits from boost::enable_shared_from_this, it provides a shared_from_this() member function that returns a valid shared_ptr instance to this.   A copy of the shared_ptr is passed to completion handlers, such as a capture-list in lambdas or passed as the instance handle to boost::bind().  This allows for the handlers to know the I/O object on which the operation was performed, and causes the lifetime of the I/O object to be extended to at least as long as the handler.  See the Boost.Asio asynchronous TCP daytime server tutorial for an example using this approach.
class tcp_connection
  : public boost::enable_shared_from_this<tcp_connection>
{
public:

  // ...

  void start()
  {
    boost::asio::async_write(socket_, ...,
        boost::bind(&tcp_connection::handle_write, shared_from_this(),
          boost::asio::placeholders::error,
          boost::asio::placeholders::bytes_transferred));
  }

  void handle_write(
    const boost::system::error_code& error,
    std::size_t bytes_transferred)
  {
    // I/O object is this->socket_.
  }

  tcp::socket socket_;
};

On the other hand, if the goal is to determine if one handler has executed before the other, then:

the application will need to explicitly manage the state
trying to manage multiple dependent call chains may be introducing unnecessary complexity and often indicates a need to reexamine the design
custom handlers could be used to prioritize the order in which handlers are executed.  The Boost.Asio Invocation example uses custom handlers that are added to a priority queue, which are then executed at a later point in time.
Comment: > However, the io_service makes no guarantees on the invocation order of handlers.

Is this still true if only one thread is executing `io_service::run()`?
Comment: @crmoore Yes.  The ordering of handlers within the `io_service` is unspecified, and the level of concurrency does not affect the ordering.
Comment: Thank you Tanner for the detailed reply. strand will definitely work. Since my io_service runs in only one thread, and cancel is requested - and apparently happens - before the read is even scheduled, is it still possible for the read completion to run first?
Comment: @StevenFaludi Yes, it is still possible.  A `strand` will guarantee the order of _handlers_, not the _operations_.  If `acceptHandler` closes `oldConnectionSocket`, initiates a read operation on `newConnectionSocket`, and later a read operation is initiated on `oldConnectionSocket`, then the order in which the read operations will be invoked and completed is unspecified.  Hence, the order in which the `ReadHandler`s will be invoked is unspecified.  See [this](http://stackoverflow.com/a/28012491/1053968) answer for more details.


Terminology Numerator Baye's Rule?

Question: I am considering this formulation of Baye's Rule
$\mathrm{Pr}(\theta | D) = \frac {\mathrm{Pr}(\theta)\mathrm{Pr}(D|\theta)}{\int \mathrm{Pr}(D|\theta)\mathrm{Pr}(\theta)\mathrm{d}\theta}$
Is there a term for the numerator? ie product of prior and likelihood?
Thanks
Mark
Answer: Numerator is $\Pr(D|\theta) \Pr(\theta) = \Pr(D, \theta)$ so it is joint probability. Or, if you'd like to keep connection with Bayes' rule, you can call it unnormalized posterior.

Terminology Numerator Baye's Rule?


Gravity forms AJAX not working with WordPress Roots/Sage theme

Question: When trying to use AJAX with Gravity Forms 1.9.9 and the Sage WordPress theme, there is the dreaded Uncaught ReferenceError: jQuery is not defined error and AJAX does not work. How can this be resolved?
Answer: If you are using the Sage theme for WordPress, jQuery is registered to load in the footer. Gravity Forms requires that jQuery is loaded in the header, so you just need to make a small change to make sure this happens.
These instructions are for the Sage theme, version 8.2.1
Open [your_theme_name]/lib/assets.php, go to line 112 (or locate wp_register_script('jquery'... ).
Simply change the final true (which specifies that the script should load in the footer to false - it should finish up like this:
wp_register_script('jquery', bower_map_to_cdn(array(
  'name' => 'jquery',
  'cdn' => 'google',
  'file' => 'jquery.min.js'
), asset_path('scripts/jquery.js')), [], null, false);

then jQuery will load in the head and your AJAX should fire up as intended.
Comment: And in case you using Soil - simply remove the add_theme_support(jquery) line from setup.php


See why an Amazon Redshift scheduled query fails

Question: I have a scheduled query in Redshift that simply will not run. It works when I execute the query manually in the query editor, just not when scheduled. I can't seem to find any feedback about why it's failing, though. I can see the schedule history, a unique Id, and the status of "Failed", but no more info.
Is there a system table/view that I can dig into and find out what's going on with my query? The SQL consists of basic select, update, insert style code - nothing fancy, just long.
Comment: Any updates on this? I see you posted this 4 months ago... maybe you figured it out since then, because I have the EXACT same question...
Comment: Nope. I eventually deleted it, and made it into a couple of smaller queries. No changes, just smaller and it worked. Very frustrating.
Answer: You can look for any errors using:
select
    process,
    errcode,
    linenum as line,
    trim(error) as err
from
    stl_error;

Also: Retrieve Redshift error messages
Ref.: STL_ERROR
Comment: this table is not accessible on redshift serverless, any alternatives?  i dont see it in sys_query_history
Answer: It says in the description that it doesn't record SQL errors which would likely be the problem of the failed query.
I'm trying to sort this one as well and it seems it's limited as I only see the

Any idea how to get the associated query ID, PID, or EID so I can check maybe against the query history?