From: 董理 on 28 Nov 2009 01:05 Hi all, I want to send an array A to MathLink, the dimensions of A are 2, 3. According to the document of MLPutRealArray, I wrote the following snippet: " double * A; double * B; long dims[2]; long * dims2; char ** heads; long d; *(A+0) = 1.1; *(A+1) = 1.2; *(A+2) = 1.3; *(A+3) = 1.4; *(A+4) = 1.5; *(A+5) = 1.6; dims[0] = 2; dims[1] = 3; MLPutFunction(link, "EvaluatePacket", 1); MLPutFunction(link, "CompoundExpression", 2); MLPutFunction(link, "Set", 2); MLPutSymbol(link, "A"); MLPutRealArray(link, A, dims, NULL, 2); MLPutSymbol(link, "Null"); MLEndPacket(link); while((packet = MLNextPacket(link)) && packet != RETURNPKT) MLNewPacket(link); MLNewPacket(link); MLPutFunction(link, "EvaluatePacket", 1); MLPutFunction(link, "ToExpression", 1); MLPutString(link, "A"); MLEndPacket(link); while((packet = MLNextPacket(link)) && packet != RETURNPKT) { printf("packet %i\n", packet); if(packet == TEXTPKT) { MLGetString(link, &text); printf("TEXTPKT:\n"); printf("%s\n", text); } MLNewPacket(link); } if(!packet) { printf("packets receiving error: %s\n", MLErrorMessage(link)); } else { if(!MLGetRealArray(link, &B, &dims2, &heads, &d)) { printf("MLGetRealArray: internal errror: %s\n", MLErrorMessage(link)); return; } } " The B is: 1.100000 1.200000 1.300000 1.400000 1.500000 So why is that? Isn't "dims" the dimensions of A? The document of MLPutRealArray and MLPutReal64Array are wrong! DONG Li
|
Pages: 1 Prev: test implication Next: to become {{f[a],g[a]},{f[b],g[b]},{f[c],g[c]}} |