2025-05-12 17:18:26 +03:00
|
|
|
package _VisualDVM.ProjectData.SapforData.Arrays;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.Utils.Index;
|
2025-05-12 17:18:26 +03:00
|
|
|
import Common.Utils.IntegerPairJson;
|
2025-04-21 15:27:20 +03:00
|
|
|
import Common.Utils.Pair;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.ProjectData.SapforData.Regions.ParallelRegion;
|
2025-05-12 17:18:26 +03:00
|
|
|
import com.google.gson.annotations.Expose;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
public class AlignRule {
|
2025-05-12 17:18:26 +03:00
|
|
|
@Expose
|
2025-05-17 18:07:07 +03:00
|
|
|
public String packedAlignArrayAddress;
|
2025-05-12 17:18:26 +03:00
|
|
|
@Expose
|
2025-05-17 18:07:07 +03:00
|
|
|
public String packedAlignWithAddress;
|
2025-05-12 17:18:26 +03:00
|
|
|
@Expose
|
|
|
|
|
public Vector<IntegerPairJson> alignRule;
|
|
|
|
|
@Expose
|
|
|
|
|
public Vector<AlignRuleWidthJson> alignRuleWith = new Vector<>();
|
|
|
|
|
//----
|
2023-09-17 22:13:42 +03:00
|
|
|
public BigInteger alignArray_address;
|
|
|
|
|
public BigInteger alignWith_address;
|
|
|
|
|
public ParallelRegion parent_region = null;
|
|
|
|
|
public AlignRule(String[] splited, Index idx) {
|
|
|
|
|
alignArray_address = new BigInteger((splited[idx.Inc()]));
|
|
|
|
|
alignWith_address = new BigInteger(splited[idx.Inc()]);
|
|
|
|
|
int alignRule_size = Integer.parseInt((splited[idx.Inc()]));
|
|
|
|
|
alignRule = new Vector<>(alignRule_size);
|
|
|
|
|
for (int i = 0; i < alignRule_size; ++i) {
|
|
|
|
|
int first = Integer.parseInt(splited[idx.Inc()]);
|
|
|
|
|
int second = Integer.parseInt(splited[idx.Inc()]);
|
2025-05-12 17:18:26 +03:00
|
|
|
alignRule.add(new IntegerPairJson(first, second));
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
int alignRuleWith_size = Integer.parseInt(splited[idx.Inc()]);
|
|
|
|
|
alignRuleWith = new Vector<>(alignRuleWith_size);
|
2025-05-12 17:18:26 +03:00
|
|
|
for (int k = 0; k < alignRuleWith_size; ++k) {
|
|
|
|
|
int dimNum = Integer.parseInt(splited[idx.Inc()]);
|
|
|
|
|
int a = Integer.parseInt(splited[idx.Inc()]);
|
|
|
|
|
int b = Integer.parseInt(splited[idx.Inc()]);
|
|
|
|
|
alignRuleWith.add(new AlignRuleWidthJson(dimNum, a, b));
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
2025-05-12 17:18:26 +03:00
|
|
|
public void Init(){
|
|
|
|
|
//--
|
2025-05-17 18:07:07 +03:00
|
|
|
if (packedAlignArrayAddress !=null)
|
|
|
|
|
alignArray_address = new BigInteger(packedAlignArrayAddress);
|
|
|
|
|
if (packedAlignWithAddress !=null)
|
|
|
|
|
alignWith_address = new BigInteger(packedAlignWithAddress);
|
2025-05-12 17:18:26 +03:00
|
|
|
//--
|
2025-05-17 18:07:07 +03:00
|
|
|
packedAlignArrayAddress = null;
|
|
|
|
|
packedAlignWithAddress = null;
|
2025-05-12 17:18:26 +03:00
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
private static Pair<String, String> convertDigitToPositive(int digit) {
|
|
|
|
|
String buf = "";
|
|
|
|
|
String sign = " + ";
|
|
|
|
|
if (digit < 0) {
|
|
|
|
|
sign = " - ";
|
|
|
|
|
int val = -digit;
|
|
|
|
|
buf += String.valueOf(val);
|
|
|
|
|
} else
|
|
|
|
|
buf += String.valueOf(digit);
|
|
|
|
|
return new Pair<>(sign, buf);
|
|
|
|
|
}
|
|
|
|
|
public ProjectArray getAlignArray() {
|
2025-05-10 17:15:45 +03:00
|
|
|
return parent_region.arraysMap.get(alignArray_address);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
public ProjectArray getAlignWith() {
|
2025-05-10 17:15:45 +03:00
|
|
|
return parent_region.arraysMap.get(alignWith_address);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
2025-05-12 17:18:26 +03:00
|
|
|
String genStringExpr(String letter, int a, int b) {
|
2023-09-17 22:13:42 +03:00
|
|
|
String retVal = "";
|
2025-05-12 17:18:26 +03:00
|
|
|
if (a == 0 && b == 0)
|
2023-09-17 22:13:42 +03:00
|
|
|
retVal = "*";
|
2025-05-12 17:18:26 +03:00
|
|
|
else if (b == 0) {
|
|
|
|
|
if (a == 1)
|
2023-09-17 22:13:42 +03:00
|
|
|
retVal = letter;
|
|
|
|
|
else {
|
2025-05-12 17:18:26 +03:00
|
|
|
Pair<String, String> digit2 = convertDigitToPositive(a);
|
2023-09-17 22:13:42 +03:00
|
|
|
if (digit2.getKey() == " - ")
|
|
|
|
|
retVal = "(-" + digit2.getValue() + ")" + " * " + letter;
|
|
|
|
|
else retVal = digit2.getValue() + " * " + letter;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2025-05-12 17:18:26 +03:00
|
|
|
Pair<String, String> digit1 = convertDigitToPositive(b);
|
|
|
|
|
if (a == 1)
|
2023-09-17 22:13:42 +03:00
|
|
|
retVal = letter + digit1.getKey() + digit1.getValue();
|
|
|
|
|
else {
|
2025-05-12 17:18:26 +03:00
|
|
|
Pair<String, String> digit2 = convertDigitToPositive(a);
|
2023-09-17 22:13:42 +03:00
|
|
|
if (digit2.getKey() == " - ")
|
|
|
|
|
retVal = "(-" + digit2.getValue() + ")" + " * " + letter + digit1.getKey() + digit1.getValue();
|
|
|
|
|
else
|
|
|
|
|
retVal = digit2.getValue() + " * " + letter + digit1.getKey() + digit1.getValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
|
|
|
|
public int GetLenString() {
|
|
|
|
|
String val = "";
|
|
|
|
|
val += getAlignArray().shortName + "(";
|
|
|
|
|
for (int i = 0; i < alignRule.size(); ++i) {
|
2025-05-12 17:18:26 +03:00
|
|
|
val += genStringExpr(ProjectArray.alignNames[i], alignRule.get(i).getKey(), alignRule.get(i).getValue());
|
2023-09-17 22:13:42 +03:00
|
|
|
if (i != alignRule.size() - 1)
|
|
|
|
|
val += ",";
|
|
|
|
|
}
|
|
|
|
|
val += ") ";
|
|
|
|
|
return val.length();
|
|
|
|
|
}
|
|
|
|
|
public Pair<String, String> GenRule(int maxArrayStringLen) {
|
|
|
|
|
getAlignArray().ac_current.clear();
|
|
|
|
|
getAlignArray().ac_new.clear();
|
|
|
|
|
getAlignArray().spaces_shift = "";
|
|
|
|
|
//------------------------------------------------------------>>>
|
|
|
|
|
getAlignArray().align_template = getAlignWith();
|
|
|
|
|
getAlignArray().parent_region = parent_region;
|
|
|
|
|
//------------------------------------------------------------>>>
|
|
|
|
|
String retVal = "";
|
|
|
|
|
String arrayString = "";
|
|
|
|
|
retVal += getAlignArray().TypeString() + " ";
|
|
|
|
|
arrayString += getAlignArray().shortName + "(";
|
|
|
|
|
for (int i = 0; i < alignRule.size(); ++i) {
|
2025-05-12 17:18:26 +03:00
|
|
|
arrayString += genStringExpr(ProjectArray.alignNames[i], alignRule.get(i).getKey(),alignRule.get(i).getValue() );
|
2023-09-17 22:13:42 +03:00
|
|
|
if (i != alignRule.size() - 1)
|
|
|
|
|
arrayString += ",";
|
|
|
|
|
}
|
|
|
|
|
arrayString += ") ";
|
|
|
|
|
for (int i = 0; i < maxArrayStringLen - arrayString.length(); ++i) {
|
|
|
|
|
getAlignArray().spaces_shift += " ";
|
|
|
|
|
}
|
|
|
|
|
retVal += getAlignArray().spaces_shift;
|
|
|
|
|
retVal += arrayString;
|
|
|
|
|
String bracket_open = "(";
|
|
|
|
|
String bracket_close = ")";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (getAlignWith().isTemplFlag > 0)
|
|
|
|
|
{
|
|
|
|
|
bracket_open = "[";
|
|
|
|
|
bracket_close = "]";
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
retVal += "→ " + getAlignWith().shortName + bracket_open;
|
|
|
|
|
Vector<String> alignEachDim = new Vector<>(getAlignWith().dimSize);
|
|
|
|
|
for (int i = 0; i < alignEachDim.capacity(); ++i)
|
|
|
|
|
alignEachDim.add("*");
|
|
|
|
|
for (int i = 0; i < alignRuleWith.size(); ++i) {
|
2025-05-12 17:18:26 +03:00
|
|
|
if (alignRuleWith.get(i).getDimNum() != -1) {
|
|
|
|
|
alignEachDim.set(alignRuleWith.get(i).getDimNum(),
|
|
|
|
|
genStringExpr(ProjectArray.alignNames[i], alignRuleWith.get(i).getA(),alignRuleWith.get(i).getB() ));
|
2023-09-17 22:13:42 +03:00
|
|
|
//коэццициенты находятся здесь!!------------------------------------------------------------------->>
|
|
|
|
|
getAlignArray().ac_current.put(i,
|
|
|
|
|
new Dimension(i,
|
2025-05-12 17:18:26 +03:00
|
|
|
alignRuleWith.get(i).getA(),
|
|
|
|
|
alignRuleWith.get(i).getB()
|
2023-09-17 22:13:42 +03:00
|
|
|
));
|
|
|
|
|
} else getAlignArray().ac_current.put(i, new Dimension(i));
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < alignEachDim.size(); ++i) {
|
|
|
|
|
retVal += alignEachDim.get(i);
|
|
|
|
|
if (i != getAlignWith().dimSize - 1)
|
|
|
|
|
retVal += ",";
|
|
|
|
|
}
|
|
|
|
|
retVal += bracket_close;// + String_.wands(alignArray.Id.ToString());
|
|
|
|
|
return new Pair<>(getAlignWith().shortName, retVal);
|
|
|
|
|
}
|
|
|
|
|
}
|