2021-07-24 02:37:17 +00:00
|
|
|
package androidx.constraintlayout.solver;
|
|
|
|
|
|
|
|
import androidx.constraintlayout.solver.ArrayRow;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.d.b.a.a;
|
2021-07-24 02:37:17 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Comparator;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class PriorityGoalRow extends ArrayRow {
|
|
|
|
private static final boolean DEBUG = false;
|
|
|
|
public static final int NOT_FOUND = -1;
|
|
|
|
private static final float epsilon = 1.0E-4f;
|
2022-03-07 09:34:54 +00:00
|
|
|
public Cache mCache;
|
2021-07-24 02:37:17 +00:00
|
|
|
private int TABLE_SIZE = 128;
|
|
|
|
private SolverVariable[] arrayGoals = new SolverVariable[128];
|
|
|
|
private SolverVariable[] sortArray = new SolverVariable[128];
|
2022-03-07 09:34:54 +00:00
|
|
|
private int numGoals = 0;
|
|
|
|
public GoalVariableAccessor accessor = new GoalVariableAccessor(this);
|
2021-07-24 02:37:17 +00:00
|
|
|
|
|
|
|
/* renamed from: androidx.constraintlayout.solver.PriorityGoalRow$1 reason: invalid class name */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class AnonymousClass1 implements Comparator<SolverVariable> {
|
|
|
|
public AnonymousClass1() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public int compare(SolverVariable solverVariable, SolverVariable solverVariable2) {
|
2021-12-17 21:59:34 +00:00
|
|
|
return solverVariable.f30id - solverVariable2.f30id;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class GoalVariableAccessor implements Comparable {
|
|
|
|
public PriorityGoalRow row;
|
|
|
|
public SolverVariable variable;
|
|
|
|
|
|
|
|
public GoalVariableAccessor(PriorityGoalRow priorityGoalRow) {
|
|
|
|
this.row = priorityGoalRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void add(SolverVariable solverVariable) {
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
|
float[] fArr = this.variable.goalStrengthVector;
|
|
|
|
fArr[i] = fArr[i] + solverVariable.goalStrengthVector[i];
|
|
|
|
if (Math.abs(fArr[i]) < 1.0E-4f) {
|
|
|
|
this.variable.goalStrengthVector[i] = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean addToGoal(SolverVariable solverVariable, float f) {
|
|
|
|
boolean z2 = true;
|
|
|
|
if (this.variable.inGoal) {
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
|
float[] fArr = this.variable.goalStrengthVector;
|
|
|
|
fArr[i] = (solverVariable.goalStrengthVector[i] * f) + fArr[i];
|
|
|
|
if (Math.abs(fArr[i]) < 1.0E-4f) {
|
|
|
|
this.variable.goalStrengthVector[i] = 0.0f;
|
|
|
|
} else {
|
|
|
|
z2 = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
PriorityGoalRow.access$000(PriorityGoalRow.this, this.variable);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (int i2 = 0; i2 < 9; i2++) {
|
|
|
|
float f2 = solverVariable.goalStrengthVector[i2];
|
|
|
|
if (f2 != 0.0f) {
|
|
|
|
float f3 = f2 * f;
|
|
|
|
if (Math.abs(f3) < 1.0E-4f) {
|
|
|
|
f3 = 0.0f;
|
|
|
|
}
|
|
|
|
this.variable.goalStrengthVector[i2] = f3;
|
|
|
|
} else {
|
|
|
|
this.variable.goalStrengthVector[i2] = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Comparable
|
|
|
|
public int compareTo(Object obj) {
|
2021-12-17 21:59:34 +00:00
|
|
|
return this.variable.f30id - ((SolverVariable) obj).f30id;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void init(SolverVariable solverVariable) {
|
|
|
|
this.variable = solverVariable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isNegative() {
|
|
|
|
for (int i = 8; i >= 0; i--) {
|
|
|
|
float f = this.variable.goalStrengthVector[i];
|
|
|
|
if (f > 0.0f) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (f < 0.0f) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isNull() {
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
|
if (this.variable.goalStrengthVector[i] != 0.0f) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isSmallerThan(SolverVariable solverVariable) {
|
|
|
|
int i = 8;
|
|
|
|
while (true) {
|
|
|
|
if (i < 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float f = solverVariable.goalStrengthVector[i];
|
|
|
|
float f2 = this.variable.goalStrengthVector[i];
|
|
|
|
if (f2 == f) {
|
|
|
|
i--;
|
|
|
|
} else if (f2 < f) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reset() {
|
|
|
|
Arrays.fill(this.variable.goalStrengthVector, 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
String str = "[ ";
|
|
|
|
if (this.variable != null) {
|
|
|
|
for (int i = 0; i < 9; i++) {
|
2022-03-21 18:52:30 +00:00
|
|
|
StringBuilder R = a.R(str);
|
|
|
|
R.append(this.variable.goalStrengthVector[i]);
|
|
|
|
R.append(" ");
|
|
|
|
str = R.toString();
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-21 18:52:30 +00:00
|
|
|
StringBuilder V = a.V(str, "] ");
|
|
|
|
V.append(this.variable);
|
|
|
|
return V.toString();
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public PriorityGoalRow(Cache cache) {
|
|
|
|
super(cache);
|
|
|
|
this.mCache = cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ void access$000(PriorityGoalRow priorityGoalRow, SolverVariable solverVariable) {
|
|
|
|
priorityGoalRow.removeGoal(solverVariable);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void addToGoal(SolverVariable solverVariable) {
|
|
|
|
int i;
|
|
|
|
int i2 = this.numGoals + 1;
|
|
|
|
SolverVariable[] solverVariableArr = this.arrayGoals;
|
|
|
|
if (i2 > solverVariableArr.length) {
|
|
|
|
SolverVariable[] solverVariableArr2 = (SolverVariable[]) Arrays.copyOf(solverVariableArr, solverVariableArr.length * 2);
|
|
|
|
this.arrayGoals = solverVariableArr2;
|
|
|
|
this.sortArray = (SolverVariable[]) Arrays.copyOf(solverVariableArr2, solverVariableArr2.length * 2);
|
|
|
|
}
|
|
|
|
SolverVariable[] solverVariableArr3 = this.arrayGoals;
|
|
|
|
int i3 = this.numGoals;
|
|
|
|
solverVariableArr3[i3] = solverVariable;
|
|
|
|
int i4 = i3 + 1;
|
|
|
|
this.numGoals = i4;
|
2021-12-17 21:59:34 +00:00
|
|
|
if (i4 > 1 && solverVariableArr3[i4 - 1].f30id > solverVariable.f30id) {
|
2021-07-24 02:37:17 +00:00
|
|
|
int i5 = 0;
|
|
|
|
while (true) {
|
|
|
|
i = this.numGoals;
|
|
|
|
if (i5 >= i) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
this.sortArray[i5] = this.arrayGoals[i5];
|
|
|
|
i5++;
|
|
|
|
}
|
|
|
|
Arrays.sort(this.sortArray, 0, i, new AnonymousClass1());
|
|
|
|
for (int i6 = 0; i6 < this.numGoals; i6++) {
|
|
|
|
this.arrayGoals[i6] = this.sortArray[i6];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
solverVariable.inGoal = true;
|
|
|
|
solverVariable.addToRow(this);
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:10:0x001c, code lost:
|
|
|
|
r5.numGoals = r2 - 1;
|
|
|
|
r6.inGoal = false;
|
|
|
|
*/
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:11:0x0022, code lost:
|
|
|
|
return;
|
|
|
|
*/
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:7:0x000c, code lost:
|
|
|
|
r2 = r5.numGoals;
|
|
|
|
*/
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:8:0x0010, code lost:
|
|
|
|
if (r1 >= (r2 - 1)) goto L_0x001c;
|
|
|
|
*/
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:9:0x0012, code lost:
|
|
|
|
r2 = r5.arrayGoals;
|
|
|
|
r3 = r1 + 1;
|
|
|
|
r2[r1] = r2[r3];
|
|
|
|
r1 = r3;
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
2021-07-24 02:37:17 +00:00
|
|
|
private final void removeGoal(SolverVariable solverVariable) {
|
|
|
|
int i = 0;
|
|
|
|
while (i < this.numGoals) {
|
|
|
|
if (this.arrayGoals[i] == solverVariable) {
|
2022-03-07 09:34:54 +00:00
|
|
|
break;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
i++;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow, androidx.constraintlayout.solver.LinearSystem.Row
|
|
|
|
public void addError(SolverVariable solverVariable) {
|
|
|
|
this.accessor.init(solverVariable);
|
|
|
|
this.accessor.reset();
|
|
|
|
solverVariable.goalStrengthVector[solverVariable.strength] = 1.0f;
|
|
|
|
addToGoal(solverVariable);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow, androidx.constraintlayout.solver.LinearSystem.Row
|
|
|
|
public void clear() {
|
|
|
|
this.numGoals = 0;
|
|
|
|
this.constantValue = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow, androidx.constraintlayout.solver.LinearSystem.Row
|
|
|
|
public SolverVariable getPivotCandidate(LinearSystem linearSystem, boolean[] zArr) {
|
|
|
|
int i = -1;
|
|
|
|
for (int i2 = 0; i2 < this.numGoals; i2++) {
|
|
|
|
SolverVariable solverVariable = this.arrayGoals[i2];
|
2021-12-17 21:59:34 +00:00
|
|
|
if (!zArr[solverVariable.f30id]) {
|
2021-07-24 02:37:17 +00:00
|
|
|
this.accessor.init(solverVariable);
|
|
|
|
if (i == -1) {
|
|
|
|
if (!this.accessor.isNegative()) {
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
i = i2;
|
|
|
|
} else {
|
|
|
|
if (!this.accessor.isSmallerThan(this.arrayGoals[i])) {
|
|
|
|
}
|
|
|
|
i = i2;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == -1) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this.arrayGoals[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow, androidx.constraintlayout.solver.LinearSystem.Row
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return this.numGoals == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow
|
|
|
|
public String toString() {
|
2022-03-21 18:52:30 +00:00
|
|
|
StringBuilder V = a.V("", " goal -> (");
|
|
|
|
V.append(this.constantValue);
|
|
|
|
V.append(") : ");
|
|
|
|
String sb = V.toString();
|
2021-07-24 02:37:17 +00:00
|
|
|
for (int i = 0; i < this.numGoals; i++) {
|
|
|
|
this.accessor.init(this.arrayGoals[i]);
|
|
|
|
sb = sb + this.accessor + " ";
|
|
|
|
}
|
|
|
|
return sb;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.ArrayRow, androidx.constraintlayout.solver.LinearSystem.Row
|
|
|
|
public void updateFromRow(LinearSystem linearSystem, ArrayRow arrayRow, boolean z2) {
|
|
|
|
SolverVariable solverVariable = arrayRow.variable;
|
|
|
|
if (solverVariable != null) {
|
|
|
|
ArrayRow.ArrayRowVariables arrayRowVariables = arrayRow.variables;
|
|
|
|
int currentSize = arrayRowVariables.getCurrentSize();
|
|
|
|
for (int i = 0; i < currentSize; i++) {
|
|
|
|
SolverVariable variable = arrayRowVariables.getVariable(i);
|
|
|
|
float variableValue = arrayRowVariables.getVariableValue(i);
|
|
|
|
this.accessor.init(variable);
|
|
|
|
if (this.accessor.addToGoal(solverVariable, variableValue)) {
|
|
|
|
addToGoal(variable);
|
|
|
|
}
|
|
|
|
this.constantValue = (arrayRow.constantValue * variableValue) + this.constantValue;
|
|
|
|
}
|
|
|
|
removeGoal(solverVariable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|