public static Localp ResizeArray001(Localp lp) { var result = new Localp(lp); result.mkarray(ELTYPES.APLPNTR, 2); var int32s = new Localp(lp); int32s.mkarray(ELTYPES.APLLONG, 10); result.Dup(int32s, new int[] { 0 }, new int[0]); var strings = new Localp(lp); strings.mkarray(ELTYPES.APLPNTR, 10); result.Dup(strings, new int[] { 1 }, new int[0]); for (var i = 0; i < 1000; i++) { if (i == result.bound(0)) { result.resizevector(i + 10, new int[] { 0 }); result.resizevector(i + 10, new int[] { 1 }); } unsafe { *(int *)(result.data(0) + i * sizeof(int)) = i; } result.stringtopock(i.ToString(), new int[] { 1, i }); } strings.Cutp(); int32s.Cutp(); return(result); }
public static Localp ComplexResultSet005(Localp lp) { var result = new Localp(lp); result.mkarray(ELTYPES.APLPNTR, 3); // resultVector result.mkarray(ELTYPES.APLPNTR, 2, 2); // resultCountVector result.mkarray(ELTYPES.APLLONG, 1, new int[] { 2, 0 }); result.int32topock(0, new int[] { 0 }); result.int32topock(0, new int[] { 1 }); // resultMatrix - resultVector[1] result.mkarray(ELTYPES.APLPNTR, new int[] { 1, 2 }, new int[] { 2, 1 }); // columnAndNullVectors[0] - resultMatrix[0,0] - values result.mkarray(ELTYPES.APLLONG, 1000, new int[] { 2, 1, 0 }); // columnAndNullVectors[1] - resultMatrix[0,1] - flags result.mkarray(ELTYPES.APLBOOL, 1000, new int[] { 2, 1, 1 }); unsafe { var index = 0; var value = 10; var flag = true; *(int *)(result.data(new int[] { 2, 1, 0 }) + index * sizeof(int)) = value; byte *bp = (byte *)result.data(new int[] { 2, 1, 1 }); long byteno = index / 8; byte bitno = (byte)(index % 8); byte boolmask = (byte)(0x80 >> bitno); bp += byteno; if (flag) { *bp |= boolmask; } else { *bp &= (byte)~boolmask; } } result.resizevector(1, new int[] { 2, 1, 0 }); result.resizevector(1, new int[] { 2, 1, 1 }); unsafe { *(int *)(result.data(new int[] { 2, 0 }) + 0 * sizeof(int)) = 1; } return(result); }