You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// done with one column. Collect stats and update parms for the next column
871
-
if(unlikely(!bv))break; // if just one product, skip the setup for next column
872
-
if(exlist==0){ // looking for nonimproving pivots?
873
+
if(bv==0){ // one product, or Dpiv
874
+
if(zv)break; // if just one product, skip the setup for next column
875
+
// here for Dpiv. bestrow+1 is the # pivots found; we add/sub/store that in the Dpiv block based on 'prirow'
876
+
exlist[colx]=exlist[colx]*!!prirow+bestrow*(prirow|1); // add/sub/init Dpiv value. Only one thread ever touches a column
877
+
}elseif(exlist==0){ // looking for nonimproving pivots?
873
878
// not looking for nonimproving pivots. Do a normal pivot-pick
874
879
// column ran to completion. Detect unbounded
875
880
if(bestrow<0){bestcolrow=bestrow; bestcol=*ndx; goto return4;} // no pivots found for a column, problem is unbounded, indicate which column in the NTT, i. e. the input value which is an identity column if < #A
--bvgrd; // undo the +1 in the product-accounting below
895
-
abortcol: // here is column aborted early, possibly on insufficient gain
900
+
abortcol: // here if column aborted early, possibly on insufficient gain
896
901
if(unlikely(!bv))break; // if just one product, skip the setup for next column
897
902
ndotprods+=bvgrd-bvgrd0+1; // accumulate # products performed, including the one we aborted out of
898
903
if(unlikely((--ncols<0)&&(SGNIF(bestcolrow,32+3)<0))){++ndx; break;} // quit if we have made a non-dangerous improvement AND have processed enough columns - include the aborted column in the count
// if ndx<m, the column is ndx {"1 M; otherwise ((((ndx-m){Ax) ];.0 Am) {"1 M) +/@:*"1 ((ndx-m){Ax) ];.0 Av
951
957
// Result for product mode (exitvec is scalar) is the product
952
958
// DIP mode
953
-
// y is ndx;Ax;Am;Av;(M, shape m,n);bkgrd;(ColThreshold,MinPivot,bkmin,NFreeCols,NCols,ImpFac,Nvirt);bk;Frow[;exclusion list;Yk]
959
+
// y is ndx;Ax;Am;Av;(M, shape m,n);bkgrd;(ColThreshold/PivTol,MinPivot,bkmin,NFreeCols,NCols,ImpFac,Virtx/Dpivdir);bk/'';Frow[;exclusion list/Dpiv;Yk]
954
960
// Result is rc,best row,best col,#cols scanned,#dot-products evaluated,best gain (if rc e. 0 1 2)
955
961
// rc,failing column of NTT, an element of ndx (if rc=4)
956
962
// rc=0 is good; rc=1 means the pivot found is dangerously small; rc=2 nonimproving pivot found; rc=3 no pivot found, stall; rc=4 means the problem is unbounded (only the failing column follows)
957
963
// rc=5 (not created - means problem is infeasible) rc=6=empty M, problem is malformed
958
964
// if the exclusion list is given, we stop on the first nonimproving pivot, and the exclusion list is used to prevent repetition of basis
959
965
// If Frow is empty, we are looking for nonimproving pivots in rows where the selector is 0. In that case the bkgrd puts the bk values in descending order. We return the first column that will make more 0 B rows non0 than non0 B rows 0.
960
-
//
966
+
// If bk is empty, we are counting the #places where c>=PivTol and accumulating into Dpiv under control of Dpivdir (-1=decr, 1=incr; init to 0 if neg)
Dbkmin; // the largest value for which bk is considered close enough to 0
1010
1016
1011
1017
if(AR(C(AAV(w)[0]))==0){
1012
-
// single index value. set bv=0 as a flag that we are storing the column
1018
+
// single index value. set bv=0, zv non0 as a flag that we are storing the column
1013
1019
bv=0; ASSERT(AN(w)==5,EVLENGTH); // if goodvec is an atom, set bv=0 to indicate that bv is not used and verify no more input
1014
1020
if(unlikely(n==0)){Rreshape(sc(n),zeroionei(0));} // empty M, each product is 0
1015
1021
GATV0(z,FL,n,1); zv=DAV(z); // allocate the result area for column extraction. Set zv nonzero so we use bkgrd of i. #M
1016
1022
bvgrd0=0; bvgrde=bvgrd0+AS(C(AAV(w)[4]))[0]; // length of column is #M
1017
1023
}else{
1018
-
// A list of index values. We are doing the DIP calculation
1024
+
// A list of index values. We are doing the DIP calculation or Dpiv
1019
1025
ASSERT(AR(C(AAV(w)[5]))==1,EVRANK); ASSERT(AN(C(AAV(w)[5]))==0||AT(C(AAV(w)[5]))&INT,EVDOMAIN); bvgrd0=IAV(C(AAV(w)[5])); bvgrde=bvgrd0+AN(C(AAV(w)[5])); // bkgrd: the order of processing the rows, and end+1 ptr normally /: bk
1020
1026
if(AN(C(AAV(w)[5]))==0){RETF(num(6))} // empty bk - give error/empty result 6
1021
1027
ASSERT(BETWEENC(AN(w),8,11),EVLENGTH);
1022
-
ASSERT(AR(C(AAV(w)[7]))<=1,EVRANK); ASSERT(AT(C(AAV(w)[7]))&FL,EVDOMAIN); ASSERT(AN(C(AAV(w)[7]))==AS(C(AAV(w)[4]))[0],EVLENGTH); bv=DAV(C(AAV(w)[7])); // bk, one per row of M
1023
1028
ASSERT(AR(C(AAV(w)[8]))<=1,EVRANK); // Frow, one per row of M and column of A
1024
1029
if(AN(C(AAV(w)[8]))==0)Frow=0;else{ASSERT(AT(C(AAV(w)[8]))&FL,EVDOMAIN); ASSERT(AN(C(AAV(w)[8]))==AS(C(AAV(w)[4]))[0]+AS(C(AAV(w)[1]))[0],EVLENGTH); Frow=DAV(C(AAV(w)[8]));} // if Frow omitted we are looking to make bks nonzero
zv=AN(C(AAV(w)[5]))==AN(C(AAV(w)[7]))?Frow:0; // set zv nonzero as a flag to process leading columns in order, until we have an improvement to shoot at. Do this only if ALL values in bk are to be processed
1030
-
if(AN(w)>9){
1031
-
ASSERT(AN(w)==11,EVLENGTH);
1032
-
// An exclusion list is given (and thus also yk). Remember their addresses. Its presence puts us through the 'nonimproving path' case
1034
+
ASSERT(AR(C(AAV(w)[7]))<=1,EVRANK);
1035
+
if(AN(C(AAV(w)[7]))!=0){
1036
+
// Normal DIP calculation
1037
+
ASSERT(AT(C(AAV(w)[7]))&FL,EVDOMAIN); ASSERT(AN(C(AAV(w)[7]))==AS(C(AAV(w)[4]))[0],EVLENGTH); bv=DAV(C(AAV(w)[7])); // bk, one per row of M
1038
+
zv=AN(C(AAV(w)[5]))==AN(C(AAV(w)[7]))?Frow:0; // set zv nonzero as a flag to process leading columns in order, until we have an improvement to shoot at. Do this only if ALL values in bk are to be processed
1039
+
if(AN(w)>9){
1040
+
// nonimproving pivots with exlist
1041
+
ASSERT(AN(w)==11,EVLENGTH);
1042
+
// An exclusion list is given (and thus also yk). Remember their addresses. Its presence puts us through the 'nonimproving path' case
1043
+
exlist=IAV(C(AAV(w)[9])); // remember address of exclusions
1044
+
nexlist=AN(C(AAV(w)[9])); // and length of list
1045
+
ASSERT(AR(C(AAV(w)[9]))<=1,EVRANK); ASSERT(nexlist==0||ISDENSETYPE(AT(C(AAV(w)[9])),INT),EVDOMAIN); // must be integer list
1046
+
ASSERT(AR(C(AAV(w)[10]))<=1,EVRANK); ASSERT(ISDENSETYPE(AT(C(AAV(w)[10])),INT),EVDOMAIN); ASSERT(AN(C(AAV(w)[10]))==AS(C(AAV(w)[4]))[0],EVLENGTH); // yk, one per row of M
1047
+
yk=IAV(C(AAV(w)[10])); // remember address of translation table of row# to basis column#
1048
+
}
1049
+
}else{
1050
+
// Dpiv counting, with Dpiv. exlist is the Dpiv area
1051
+
ASSERT(AN(w)==10,EVLENGTH);
1052
+
bv=zv=0;
1033
1053
exlist=IAV(C(AAV(w)[9])); // remember address of exclusions
1034
-
nexlist=AN(C(AAV(w)[9])); // and length of list
1035
-
ASSERT(AR(C(AAV(w)[9]))<=1,EVRANK); ASSERT(nexlist==0||ISDENSETYPE(AT(C(AAV(w)[9])),INT),EVDOMAIN); // must be integer list
1036
-
ASSERT(AR(C(AAV(w)[10]))<=1,EVRANK); ASSERT(ISDENSETYPE(AT(C(AAV(w)[10])),INT),EVDOMAIN); ASSERT(AN(C(AAV(w)[10]))==AS(C(AAV(w)[4]))[0],EVLENGTH); // yk, one per row of M
1037
-
yk=IAV(C(AAV(w)[10])); // remember address of translation table of row# to basis column#
1054
+
ASSERT(AR(C(AAV(w)[9]))==1,EVRANK); ASSERT(ISDENSETYPE(AT(C(AAV(w)[9])),INT),EVDOMAIN); // must be integer list
1055
+
ASSERT(AN(C(AAV(w)[9]))==AS(C(AAV(w)[2]))[0]+AS(C(AAV(w)[4]))[0],EVLENGTH); // length of Dpiv is #cols of A + #rows of A (=M)
1056
+
z=mtv; // no error is possible; use harmless return value
0 commit comments