public int[][] getIndicesPartitionMapping() { ensurePartitionInitialized(); return ArraysUtils.deepClone(indicesPartitionMapping); }
private void ensurePartitionInitialized() { if (indicesPartitionMapping != null) return; if (!isDerivative()) { int[][] ret = new int[structuresOfIndices.length][]; Arrays.fill(ret, 1, ret.length, new int[0]); ret[0] = ArraysUtils.getSeriesFrom0(structuresOfIndices[0].size()); indicesPartitionMapping = ret; } NameDescriptorForTensorField parent = getParent(); StructureOfIndices[] partition = new StructureOfIndices[ArraysUtils.sum(orders) + 1]; partition[0] = parent.getStructureOfIndices(); int i, j; int totalOrder = 1; for (i = 0; i < structuresOfIndices.length - 1; ++i) { for (j = orders[i] - 1; j >= 0; --j) partition[totalOrder++] = parent.getArgStructureOfIndices(i); } indicesPartitionMapping = structuresOfIndices[0].getPartitionMappings(partition); }
/** * Returns the order of derivative with respect to argument at specified position. * * @return the order of derivative with respect to argument at specified position */ public int getDeivativeOrder(int i) { return getNameDescriptor().getDerivativeOrder(i); }
/** * Return tensor field from which the derivative is taken. If {@code this} is derivative (e.g. {@code f_m~(1)[k_a]}), * returns target tensor field of {@code this} (i.e. {@code f[k_a]}); otherwise, returns {@code this}. * * @return tensor field from which the derivative is taken */ public TensorField getParentField() { if (!isDerivative()) return this; return Tensors.field(getNameDescriptor().getParent().getId(), getPartitionOfIndices()[0][0], args); }
orders[argPosition] = order; NameDescriptorForTensorField fieldDescriptor = parent.getNameDescriptor(); NameDescriptor derivativeDescriptor = fieldDescriptor.getDerivative(orders); if (!fieldDescriptor.isDerivative() || derivativeIndices.size() == 0 || parent.indices.size() == 0) { totalIndices = new SimpleIndicesBuilder().append(parent.getIndices()).append(derivativeIndices).getIndices(); } else { orders = fieldDescriptor.getDerivativeOrders(); StructureOfIndices[] structures = fieldDescriptor.getStructuresOfIndices(); int i, from; SimpleIndices singleType; eType = IndexType.values()[type]; singleType = parent.getIndices().getOfType(eType); from = fieldDescriptor.getParent().getStructureOfIndices().getTypeData(type).length; for (i = 0; i <= argPosition; ++i) from += structures[i + 1].getTypeData(type).length * orders[i];
if (currentDescriptor.getParent().getId() != fromDescriptor.getParent().getId()) return currentNode; if (currentDescriptor.getDerivativeOrder(i) < fromDescriptor.getDerivativeOrder(i)) return currentNode; IntArray orders = new IntArray(currentDescriptor.getDerivativeOrders()); DFromTo derivative = derivatives.get(orders); if (derivative == null) {
if (!fieldDescriptor.isDerivative()) { SimpleIndices[][] ret = new SimpleIndices[args.length + 1][]; Arrays.fill(ret, 1, ret.length, new SimpleIndices[0]); int[] orders = fieldDescriptor.getDerivativeOrders(); int[][] _mapping = fieldDescriptor.getIndicesPartitionMapping();
public PrimitiveTensorFieldSubstitution(Tensor from, Tensor to) { super(from, to); this.fromDescriptor = ((TensorField) from).getNameDescriptor(); this.orders = new IntArray(fromDescriptor.getDerivativeOrders()); this.derivatives.put(this.orders, new DFromTo((TensorField) from, to)); }
(NameDescriptorForTensorField) CC.getNameManager().mapNameDescriptor(name, structures); NameDescriptor derivativeDescriptor = fieldDescriptor.getDerivative(orders);
private static TIntHashSet addSimpleTensorsNames(Tensor t, TIntHashSet names) { if (t instanceof TensorField) names.add(((TensorField) t).getNameDescriptor().getParent().getId()); if (t instanceof SimpleTensor) names.add(((SimpleTensor) t).getName()); for (Tensor tt : t) addSimpleTensorsNames(tt, names); return names; }
private static boolean testContainsNames(Tensor t, TIntHashSet names) { if (t instanceof TensorField) { if (names.contains(((TensorField) t).getNameDescriptor().getParent().getId())) return true; } else if (t instanceof SimpleTensor) return names.contains(((SimpleTensor) t).getName()); for (Tensor tt : t) if (testContainsNames(tt, names)) return true; return false; }