private int currentElement() { int value = 0; for (int ii = 0; ii < getRank(); ii++) value += odo[ii] * stride[ii]; return value; } }
private int currentElement() { int value = 0; for (int ii = 0; ii < getRank(); ii++) value += odo[ii] * stride[ii]; return value; } } // Section.Iterator
private int currentElement() { int value = 0; for (int ii = 0; ii < getRank(); ii++) value += odo[ii] * stride[ii]; return value; } }
/** * Compare this section with another upto the vlen in either */ public boolean compatibleRank(Section other) { return (getRank() == other.getRank()); /*if((isVariableLength() && other.isVariableLength()) || (!isVariableLength() && !other.isVariableLength())) return getRank() == other.getRank(); else if(isVariableLength() && !other.isVariableLength()) return getVlenRank() == other.getRank(); else // !isVariableLength() && other.isVariableLength() return getRank() == other.getVlenRank(); */ }
/** * Compare this section with another upto the vlen in either */ public boolean compatibleRank(Section other) { return (getRank() == other.getRank()); /*if((isVariableLength() && other.isVariableLength()) || (!isVariableLength() && !other.isVariableLength())) return getRank() == other.getRank(); else if(isVariableLength() && !other.isVariableLength()) return getVlenRank() == other.getRank(); else // !isVariableLength() && other.isVariableLength() return getRank() == other.getVlenRank(); */ }
public Section shiftOrigin(int[] newOrigin) throws InvalidRangeException { if (newOrigin.length != getRank()) throw new InvalidRangeException("Invalid Section rank"); List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); results.add(base.shiftOrigin(-newOrigin[j])); } return new Section(results); }
public Section removeFirst(Section parentSection) { int parentSize = parentSection.getRank(); assert parentSize <= list.size(); if (parentSize == list.size()) return new Section(); // scalar return subSection(parentSize, list.size()); }
/** * Create a new Section by compacting each Range. * first = first/stride, last=last/stride, stride=1. * * @return compacted Section * @throws InvalidRangeException elements must be nonnegative, 0 <= first <= last */ public Section compact() throws InvalidRangeException { List<Range> results = new ArrayList<>(getRank()); for (Range r : list) { results.add(r.compact()); } return new Section(results); }
/** * Create a new Section by compacting each Range. * first = first/stride, last=last/stride, stride=1. * * @return compacted Section * @throws InvalidRangeException elements must be nonnegative, 0 <= first <= last */ public Section compact() throws InvalidRangeException { List<Range> results = new ArrayList<Range>(getRank()); for (Range r : list) { results.add(r.compact()); } return new Section(results); }
/** * Create a new Section by compacting each Range. * first = first/stride, last=last/stride, stride=1. * * @return compacted Section * @throws InvalidRangeException elements must be nonnegative, 0 <= first <= last */ public Section compact() throws InvalidRangeException { List<Range> results = new ArrayList<>(getRank()); for (Range r : list) { results.add(r.compact()); } return new Section(results); }
Iterator(int[] shape) { int ss = 1; for (int i = getRank() - 1; i >= 0; i--) { // fastest varying last stride[i] = ss; ss *= shape[i]; } for (int i = 0; i < getRank(); i++) { java.util.Iterator<Integer> iter = getRange(i).iterator(); odo[i] = iter.next(); rangeIterList.add(iter); } done = 0; total = Index.computeSize(getShape()); // total in the section }
public int offset(Section intersect) throws InvalidRangeException { if (intersect.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); int result = 0; int stride = 1; for (int j = list.size() - 1; j >= 0; j--) { Range base = list.get(j); Range r = intersect.getRange(j); int offset = base.index(r.first()); result += offset * stride; stride *= base.length(); } return result; }
public Section addRangeNames(List<String> rangeNames) throws InvalidRangeException { if (rangeNames.size() != getRank()) throw new InvalidRangeException("Invalid number of Range Names"); int count = 0; Section result = new Section(); for (Range r : getRanges()) { Range nr = new Range(rangeNames.get(count++), r); result.appendRange(nr); } return result; }
public Section addRangeNames(List<String> rangeNames) throws InvalidRangeException { if (rangeNames.size() != getRank()) throw new InvalidRangeException("Invalid number of Range Names"); int count = 0; Section result = new Section(); for (Range r : getRanges()) { Range nr = r.setName(rangeNames.get(count++)); result.appendRange(nr); } return result; }
public Section addRangeNames(List<String> rangeNames) throws InvalidRangeException { if (rangeNames.size() != getRank()) throw new InvalidRangeException("Invalid number of Range Names"); int count = 0; Section result = new Section(); for (Range r : getRanges()) { Range nr = new Range(rangeNames.get(count++), r); result.appendRange(nr); } return result; }
private void incr() { int digit = getRank() - 1; while (digit >= 0) { Range r = getRange(digit); odo[digit] += r.stride(); if (odo[digit] <= r.last()) break; // normal exit odo[digit] = r.first(); // else, carry digit--; assert digit >= 0; // catch screw-ups } }
Iterator(int[] shape) { int ss = 1; for (int i = getRank() - 1; i >= 0; i--) { odo[i] = getRange(i).first(); stride[i] = ss; ss *= shape[i]; } done = 0; total = Index.computeSize(getShape()); // total in the section }
Iterator(int[] shape) { int ss = 1; for (int i = getRank() - 1; i >= 0; i--) { odo[i] = getRange(i).first(); stride[i] = ss; ss *= shape[i]; } done = 0; total = Index.computeSize(getShape()); // total in the section }
private void incr() { int digit = getRank() - 1; while (digit >= 0) { Range r = getRange(digit); odo[digit] += r.stride(); if (odo[digit] <= r.last()) break; // normal exit odo[digit] = r.first(); // else, carry digit--; assert digit >= 0; // catch screw-ups } }