id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
100,300
softindex/datakernel
cloud-dataflow/src/main/java/io/datakernel/dataflow/server/DatagraphEnvironment.java
DatagraphEnvironment.with
@SuppressWarnings("unchecked") public DatagraphEnvironment with(Object key, Object value) { ((Map<Object, Object>) instances).put(key, value); return this; }
java
@SuppressWarnings("unchecked") public DatagraphEnvironment with(Object key, Object value) { ((Map<Object, Object>) instances).put(key, value); return this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "DatagraphEnvironment", "with", "(", "Object", "key", ",", "Object", "value", ")", "{", "(", "(", "Map", "<", "Object", ",", "Object", ">", ")", "instances", ")", ".", "put", "(", "key", ",", ...
Sets the given value for the specified key. @param key key @param value value @return this environment
[ "Sets", "the", "given", "value", "for", "the", "specified", "key", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-dataflow/src/main/java/io/datakernel/dataflow/server/DatagraphEnvironment.java#L66-L70
100,301
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufStrings.java
ByteBufStrings.encodeUtf8
public static int encodeUtf8(byte[] array, int pos, String string) { int p = pos; for (int i = 0; i < string.length(); i++) { p += encodeUtf8(array, p, string.charAt(i)); } return p - pos; }
java
public static int encodeUtf8(byte[] array, int pos, String string) { int p = pos; for (int i = 0; i < string.length(); i++) { p += encodeUtf8(array, p, string.charAt(i)); } return p - pos; }
[ "public", "static", "int", "encodeUtf8", "(", "byte", "[", "]", "array", ",", "int", "pos", ",", "String", "string", ")", "{", "int", "p", "=", "pos", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "string", ".", "length", "(", ")", ";",...
UTF-8
[ "UTF", "-", "8" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufStrings.java#L214-L220
100,302
softindex/datakernel
core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java
ReflectionUtils.fetchAnnotationElementValue
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException { Object value = element.invoke(annotation); if (value == null) { String errorMsg = "@" + annotation.annotationType().getName() + "." + element.getName() + "() returned null"; throw...
java
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException { Object value = element.invoke(annotation); if (value == null) { String errorMsg = "@" + annotation.annotationType().getName() + "." + element.getName() + "() returned null"; throw...
[ "public", "static", "Object", "fetchAnnotationElementValue", "(", "Annotation", "annotation", ",", "Method", "element", ")", "throws", "ReflectiveOperationException", "{", "Object", "value", "=", "element", ".", "invoke", "(", "annotation", ")", ";", "if", "(", "v...
Returns values if it is not null, otherwise throws exception
[ "Returns", "values", "if", "it", "is", "not", "null", "otherwise", "throws", "exception" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-eventloop/src/main/java/io/datakernel/util/ReflectionUtils.java#L387-L395
100,303
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java
ClassBuilder.withField
public ClassBuilder<T> withField(String field, Class<?> fieldClass) { fields.put(field, fieldClass); return this; }
java
public ClassBuilder<T> withField(String field, Class<?> fieldClass) { fields.put(field, fieldClass); return this; }
[ "public", "ClassBuilder", "<", "T", ">", "withField", "(", "String", "field", ",", "Class", "<", "?", ">", "fieldClass", ")", "{", "fields", ".", "put", "(", "field", ",", "fieldClass", ")", ";", "return", "this", ";", "}" ]
Creates a new field for a dynamic class @param field name of field @param fieldClass type of field @return changed AsmFunctionFactory
[ "Creates", "a", "new", "field", "for", "a", "dynamic", "class" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java#L161-L164
100,304
softindex/datakernel
core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java
ClassBuilder.withMethod
public ClassBuilder<T> withMethod(String methodName, Expression expression) { if (methodName.contains("(")) { Method method = Method.getMethod(methodName); return withMethod(method, expression); } Method foundMethod = null; List<List<java.lang.reflect.Method>> listOfMethods = new ArrayList<>(); listOfM...
java
public ClassBuilder<T> withMethod(String methodName, Expression expression) { if (methodName.contains("(")) { Method method = Method.getMethod(methodName); return withMethod(method, expression); } Method foundMethod = null; List<List<java.lang.reflect.Method>> listOfMethods = new ArrayList<>(); listOfM...
[ "public", "ClassBuilder", "<", "T", ">", "withMethod", "(", "String", "methodName", ",", "Expression", "expression", ")", "{", "if", "(", "methodName", ".", "contains", "(", "\"(\"", ")", ")", "{", "Method", "method", "=", "Method", ".", "getMethod", "(", ...
CCreates a new method for a dynamic class @param methodName name of method @param expression function which will be processed @return changed AsmFunctionFactory
[ "CCreates", "a", "new", "method", "for", "a", "dynamic", "class" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-codegen/src/main/java/io/datakernel/codegen/ClassBuilder.java#L233-L260
100,305
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/AbstractStreamSupplier.java
AbstractStreamSupplier.setConsumer
@Override public final void setConsumer(StreamConsumer<T> consumer) { checkNotNull(consumer); checkState(this.consumer == null, "Consumer has already been set"); checkState(getCapabilities().contains(LATE_BINDING) || eventloop.tick() == createTick, LATE_BINDING_ERROR_MESSAGE, this); this.consumer = consum...
java
@Override public final void setConsumer(StreamConsumer<T> consumer) { checkNotNull(consumer); checkState(this.consumer == null, "Consumer has already been set"); checkState(getCapabilities().contains(LATE_BINDING) || eventloop.tick() == createTick, LATE_BINDING_ERROR_MESSAGE, this); this.consumer = consum...
[ "@", "Override", "public", "final", "void", "setConsumer", "(", "StreamConsumer", "<", "T", ">", "consumer", ")", "{", "checkNotNull", "(", "consumer", ")", ";", "checkState", "(", "this", ".", "consumer", "==", "null", ",", "\"Consumer has already been set\"", ...
Sets consumer for this supplier. At the moment of calling this method supplier shouldn't have consumer, as well as consumer shouldn't have supplier, otherwise there will be error @param consumer consumer for streaming
[ "Sets", "consumer", "for", "this", "supplier", ".", "At", "the", "moment", "of", "calling", "this", "method", "supplier", "shouldn", "t", "have", "consumer", "as", "well", "as", "consumer", "shouldn", "t", "have", "supplier", "otherwise", "there", "will", "b...
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/AbstractStreamSupplier.java#L79-L91
100,306
softindex/datakernel
cloud-dataflow/src/main/java/io/datakernel/dataflow/graph/DataGraph.java
DataGraph.execute
public void execute() { Map<Partition, List<Node>> map = getNodesByPartition(); for (Partition partition : map.keySet()) { List<Node> nodes = map.get(partition); partition.execute(nodes); } }
java
public void execute() { Map<Partition, List<Node>> map = getNodesByPartition(); for (Partition partition : map.keySet()) { List<Node> nodes = map.get(partition); partition.execute(nodes); } }
[ "public", "void", "execute", "(", ")", "{", "Map", "<", "Partition", ",", "List", "<", "Node", ">", ">", "map", "=", "getNodesByPartition", "(", ")", ";", "for", "(", "Partition", "partition", ":", "map", ".", "keySet", "(", ")", ")", "{", "List", ...
Executes the defined operations on all partitions.
[ "Executes", "the", "defined", "operations", "on", "all", "partitions", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/cloud-dataflow/src/main/java/io/datakernel/dataflow/graph/DataGraph.java#L69-L75
100,307
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createFor
@Override public DynamicMBean createFor(List<?> monitorables, MBeanSettings setting, boolean enableRefresh) { checkNotNull(monitorables); checkArgument(monitorables.size() > 0, "Size of list of monitorables should be greater than 0"); checkArgument(monitorables.stream().noneMatch(Objects::isNull), "Monitorable c...
java
@Override public DynamicMBean createFor(List<?> monitorables, MBeanSettings setting, boolean enableRefresh) { checkNotNull(monitorables); checkArgument(monitorables.size() > 0, "Size of list of monitorables should be greater than 0"); checkArgument(monitorables.stream().noneMatch(Objects::isNull), "Monitorable c...
[ "@", "Override", "public", "DynamicMBean", "createFor", "(", "List", "<", "?", ">", "monitorables", ",", "MBeanSettings", "setting", ",", "boolean", "enableRefresh", ")", "{", "checkNotNull", "(", "monitorables", ")", ";", "checkArgument", "(", "monitorables", "...
Creates Jmx MBean for monitorables with operations and attributes.
[ "Creates", "Jmx", "MBean", "for", "monitorables", "with", "operations", "and", "attributes", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L113-L171
100,308
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.handleJmxRefreshables
private void handleJmxRefreshables(List<MBeanWrapper> mbeanWrappers, AttributeNodeForPojo rootNode) { for (MBeanWrapper mbeanWrapper : mbeanWrappers) { Eventloop eventloop = mbeanWrapper.getEventloop(); List<JmxRefreshable> currentRefreshables = rootNode.getAllRefreshables(mbeanWrapper.getMBean()); if (!even...
java
private void handleJmxRefreshables(List<MBeanWrapper> mbeanWrappers, AttributeNodeForPojo rootNode) { for (MBeanWrapper mbeanWrapper : mbeanWrappers) { Eventloop eventloop = mbeanWrapper.getEventloop(); List<JmxRefreshable> currentRefreshables = rootNode.getAllRefreshables(mbeanWrapper.getMBean()); if (!even...
[ "private", "void", "handleJmxRefreshables", "(", "List", "<", "MBeanWrapper", ">", "mbeanWrappers", ",", "AttributeNodeForPojo", "rootNode", ")", "{", "for", "(", "MBeanWrapper", "mbeanWrapper", ":", "mbeanWrappers", ")", "{", "Eventloop", "eventloop", "=", "mbeanWr...
region refreshing jmx
[ "region", "refreshing", "jmx" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L543-L559
100,309
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createAttributesTree
private AttributeNodeForPojo createAttributesTree(Class<?> clazz, Map<Type, JmxCustomTypeAdapter<?>> customTypes) { List<AttributeNode> subNodes = createNodesFor(clazz, clazz, new String[0], null, customTypes); return new AttributeNodeForPojo("", null, true, new ValueFetcherDirect(), null, subNodes); }
java
private AttributeNodeForPojo createAttributesTree(Class<?> clazz, Map<Type, JmxCustomTypeAdapter<?>> customTypes) { List<AttributeNode> subNodes = createNodesFor(clazz, clazz, new String[0], null, customTypes); return new AttributeNodeForPojo("", null, true, new ValueFetcherDirect(), null, subNodes); }
[ "private", "AttributeNodeForPojo", "createAttributesTree", "(", "Class", "<", "?", ">", "clazz", ",", "Map", "<", "Type", ",", "JmxCustomTypeAdapter", "<", "?", ">", ">", "customTypes", ")", "{", "List", "<", "AttributeNode", ">", "subNodes", "=", "createNodes...
Creates attribute tree of Jmx attributes for clazz.
[ "Creates", "attribute", "tree", "of", "Jmx", "attributes", "for", "clazz", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L603-L606
100,310
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.createMBeanInfo
private static MBeanInfo createMBeanInfo(AttributeNodeForPojo rootNode, Class<?> monitorableClass) { String monitorableName = ""; String monitorableDescription = ""; MBeanAttributeInfo[] attributes = rootNode != null ? fetchAttributesInfo(rootNode) : new MBeanAttributeInfo[0]; MBeanOperationInfo[] opera...
java
private static MBeanInfo createMBeanInfo(AttributeNodeForPojo rootNode, Class<?> monitorableClass) { String monitorableName = ""; String monitorableDescription = ""; MBeanAttributeInfo[] attributes = rootNode != null ? fetchAttributesInfo(rootNode) : new MBeanAttributeInfo[0]; MBeanOperationInfo[] opera...
[ "private", "static", "MBeanInfo", "createMBeanInfo", "(", "AttributeNodeForPojo", "rootNode", ",", "Class", "<", "?", ">", "monitorableClass", ")", "{", "String", "monitorableName", "=", "\"\"", ";", "String", "monitorableDescription", "=", "\"\"", ";", "MBeanAttrib...
region creating jmx metadata - MBeanInfo
[ "region", "creating", "jmx", "metadata", "-", "MBeanInfo" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L610-L624
100,311
softindex/datakernel
boot/src/main/java/io/datakernel/jmx/JmxMBeans.java
JmxMBeans.fetchOpkeyToMethod
private static Map<OperationKey, Method> fetchOpkeyToMethod(Class<?> mbeanClass) { Map<OperationKey, Method> opkeyToMethod = new HashMap<>(); Method[] methods = mbeanClass.getMethods(); for (Method method : methods) { if (method.isAnnotationPresent(JmxOperation.class)) { JmxOperation annotation = method.ge...
java
private static Map<OperationKey, Method> fetchOpkeyToMethod(Class<?> mbeanClass) { Map<OperationKey, Method> opkeyToMethod = new HashMap<>(); Method[] methods = mbeanClass.getMethods(); for (Method method : methods) { if (method.isAnnotationPresent(JmxOperation.class)) { JmxOperation annotation = method.ge...
[ "private", "static", "Map", "<", "OperationKey", ",", "Method", ">", "fetchOpkeyToMethod", "(", "Class", "<", "?", ">", "mbeanClass", ")", "{", "Map", "<", "OperationKey", ",", "Method", ">", "opkeyToMethod", "=", "new", "HashMap", "<>", "(", ")", ";", "...
region jmx operations fetching
[ "region", "jmx", "operations", "fetching" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/boot/src/main/java/io/datakernel/jmx/JmxMBeans.java#L714-L737
100,312
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpClientConnection.java
HttpClientConnection.send
public Promise<HttpResponse> send(HttpRequest request) { SettablePromise<HttpResponse> promise = new SettablePromise<>(); this.promise = promise; assert pool == null; (pool = client.poolReadWrite).addLastNode(this); poolTimestamp = eventloop.currentTimeMillis(); HttpHeaderValue connectionHeader = CONNECTION...
java
public Promise<HttpResponse> send(HttpRequest request) { SettablePromise<HttpResponse> promise = new SettablePromise<>(); this.promise = promise; assert pool == null; (pool = client.poolReadWrite).addLastNode(this); poolTimestamp = eventloop.currentTimeMillis(); HttpHeaderValue connectionHeader = CONNECTION...
[ "public", "Promise", "<", "HttpResponse", ">", "send", "(", "HttpRequest", "request", ")", "{", "SettablePromise", "<", "HttpResponse", ">", "promise", "=", "new", "SettablePromise", "<>", "(", ")", ";", "this", ".", "promise", "=", "promise", ";", "assert",...
Sends the request, recycles it and closes connection in case of timeout @param request request for sending
[ "Sends", "the", "request", "recycles", "it", "and", "closes", "connection", "in", "case", "of", "timeout" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpClientConnection.java#L232-L260
100,313
softindex/datakernel
core-http/src/main/java/io/datakernel/http/HttpClientConnection.java
HttpClientConnection.onClosed
@Override protected void onClosed() { assert promise == null; if (pool == client.poolKeepAlive) { AddressLinkedList addresses = client.addresses.get(remoteAddress); addresses.removeNode(this); if (addresses.isEmpty()) { client.addresses.remove(remoteAddress); } } // pool will be null if socket...
java
@Override protected void onClosed() { assert promise == null; if (pool == client.poolKeepAlive) { AddressLinkedList addresses = client.addresses.get(remoteAddress); addresses.removeNode(this); if (addresses.isEmpty()) { client.addresses.remove(remoteAddress); } } // pool will be null if socket...
[ "@", "Override", "protected", "void", "onClosed", "(", ")", "{", "assert", "promise", "==", "null", ";", "if", "(", "pool", "==", "client", ".", "poolKeepAlive", ")", "{", "AddressLinkedList", "addresses", "=", "client", ".", "addresses", ".", "get", "(", ...
After closing this connection it removes it from its connections cache and recycles Http response.
[ "After", "closing", "this", "connection", "it", "removes", "it", "from", "its", "connections", "cache", "and", "recycles", "Http", "response", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpClientConnection.java#L266-L287
100,314
softindex/datakernel
core-http/src/main/java/io/datakernel/http/AsyncHttpClient.java
AsyncHttpClient.request
@Override public Promise<HttpResponse> request(HttpRequest request) { assert eventloop.inEventloopThread(); if (inspector != null) inspector.onRequest(request); String host = request.getUrl().getHost(); assert host != null; return asyncDnsClient.resolve4(host) .thenEx((dnsResponse, e) -> { if (e =...
java
@Override public Promise<HttpResponse> request(HttpRequest request) { assert eventloop.inEventloopThread(); if (inspector != null) inspector.onRequest(request); String host = request.getUrl().getHost(); assert host != null; return asyncDnsClient.resolve4(host) .thenEx((dnsResponse, e) -> { if (e =...
[ "@", "Override", "public", "Promise", "<", "HttpResponse", ">", "request", "(", "HttpRequest", "request", ")", "{", "assert", "eventloop", ".", "inEventloopThread", "(", ")", ";", "if", "(", "inspector", "!=", "null", ")", "inspector", ".", "onRequest", "(",...
Sends the request to server, waits the result timeout and handles result with callback @param request request for server
[ "Sends", "the", "request", "to", "server", "waits", "the", "result", "timeout", "and", "handles", "result", "with", "callback" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/AsyncHttpClient.java#L333-L357
100,315
softindex/datakernel
core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufPool.java
ByteBufPool.clear
public static void clear() { for (int i = 0; i < ByteBufPool.NUMBER_OF_SLABS; i++) { slabs[i].clear(); created[i].set(0); reused[i].set(0); } synchronized (registry) { registry.clear(); } }
java
public static void clear() { for (int i = 0; i < ByteBufPool.NUMBER_OF_SLABS; i++) { slabs[i].clear(); created[i].set(0); reused[i].set(0); } synchronized (registry) { registry.clear(); } }
[ "public", "static", "void", "clear", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ByteBufPool", ".", "NUMBER_OF_SLABS", ";", "i", "++", ")", "{", "slabs", "[", "i", "]", ".", "clear", "(", ")", ";", "created", "[", "i", "]",...
Clears all of the slabs and stats.
[ "Clears", "all", "of", "the", "slabs", "and", "stats", "." ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBufPool.java#L330-L339
100,316
softindex/datakernel
core-eventloop/src/main/java/io/datakernel/eventloop/OptimizedSelectedKeysSet.java
OptimizedSelectedKeysSet.ensureCapacity
private void ensureCapacity() { if (size < selectionKeys.length) { return; } SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2]; System.arraycopy(selectionKeys, 0, newArray, 0, size); selectionKeys = newArray; }
java
private void ensureCapacity() { if (size < selectionKeys.length) { return; } SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2]; System.arraycopy(selectionKeys, 0, newArray, 0, size); selectionKeys = newArray; }
[ "private", "void", "ensureCapacity", "(", ")", "{", "if", "(", "size", "<", "selectionKeys", ".", "length", ")", "{", "return", ";", "}", "SelectionKey", "[", "]", "newArray", "=", "new", "SelectionKey", "[", "selectionKeys", ".", "length", "*", "2", "]"...
Multiply the size of array twice
[ "Multiply", "the", "size", "of", "array", "twice" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-eventloop/src/main/java/io/datakernel/eventloop/OptimizedSelectedKeysSet.java#L39-L46
100,317
softindex/datakernel
core-datastream/src/main/java/io/datakernel/stream/processor/StreamSorter.java
StreamSorter.create
public static <K, T> StreamSorter<K, T> create(StreamSorterStorage<T> storage, Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct, int itemsInMemorySize) { return new StreamSorter<>(storage, keyFunction, keyComparator, distinct, itemsInMemorySize); }
java
public static <K, T> StreamSorter<K, T> create(StreamSorterStorage<T> storage, Function<T, K> keyFunction, Comparator<K> keyComparator, boolean distinct, int itemsInMemorySize) { return new StreamSorter<>(storage, keyFunction, keyComparator, distinct, itemsInMemorySize); }
[ "public", "static", "<", "K", ",", "T", ">", "StreamSorter", "<", "K", ",", "T", ">", "create", "(", "StreamSorterStorage", "<", "T", ">", "storage", ",", "Function", "<", "T", ",", "K", ">", "keyFunction", ",", "Comparator", "<", "K", ">", "keyCompa...
Creates a new instance of StreamSorter @param storage storage for storing elements which was no placed to RAM @param keyFunction function for searching key @param keyComparator comparator for comparing key @param distinct if it is true it means that in result will be not objects with same ...
[ "Creates", "a", "new", "instance", "of", "StreamSorter" ]
090ca1116416c14d463d49d275cb1daaafa69c56
https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-datastream/src/main/java/io/datakernel/stream/processor/StreamSorter.java#L139-L143
100,318
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java
EquationsBFGS.update
public static void update(DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double p = VectorVectorMult_DDRM.innerProd(y,s); if( p == 0 ) return; p = 1.0/p; double sBs = VectorVectorMult_DDRM.innerProdA(s,H,s); if( sBs == 0 ) return; ...
java
public static void update(DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double p = VectorVectorMult_DDRM.innerProd(y,s); if( p == 0 ) return; p = 1.0/p; double sBs = VectorVectorMult_DDRM.innerProdA(s,H,s); if( sBs == 0 ) return; ...
[ "public", "static", "void", "update", "(", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "s", ",", "DMatrixRMaj", "y", ",", "DMatrixRMaj", "tempV0", ",", "DMatrixRMaj", "tempV1", ")", "{", "double", "p", "=", "VectorVectorMult_DDRM", ".", "innerProd", "(", "y", ",...
DFP Hessian update equation. See class description for equations @param H symmetric inverse matrix being updated @param s change in state (new - old) @param y change in gradient (new - old) @param tempV0 Storage vector
[ "DFP", "Hessian", "update", "equation", ".", "See", "class", "description", "for", "equations" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java#L62-L82
100,319
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java
EquationsBFGS.inverseUpdate
public static void inverseUpdate( DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double alpha = VectorVectorMult_DDRM.innerProdA(y,H,y); double p = 1.0/VectorVectorMult_DDRM.innerProd(s,y); CommonOps_DDRM.mult(H,y,tempV0); CommonOps_DDRM.multTransA(y, H, t...
java
public static void inverseUpdate( DMatrixRMaj H , DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj tempV0, DMatrixRMaj tempV1) { double alpha = VectorVectorMult_DDRM.innerProdA(y,H,y); double p = 1.0/VectorVectorMult_DDRM.innerProd(s,y); CommonOps_DDRM.mult(H,y,tempV0); CommonOps_DDRM.multTransA(y, H, t...
[ "public", "static", "void", "inverseUpdate", "(", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "s", ",", "DMatrixRMaj", "y", ",", "DMatrixRMaj", "tempV0", ",", "DMatrixRMaj", "tempV1", ")", "{", "double", "alpha", "=", "VectorVectorMult_DDRM", ".", "innerProdA", "(",...
BFGS inverse hessian update equation that orders the multiplications to minimize the number of operations. @param H symmetric inverse matrix being updated @param s change in state @param y change in gradient @param tempV0 Storage vector of length N @param tempV1 Storage vector of length N
[ "BFGS", "inverse", "hessian", "update", "equation", "that", "orders", "the", "multiplications", "to", "minimize", "the", "number", "of", "operations", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/EquationsBFGS.java#L93-L105
100,320
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/UtilOptimize.java
UtilOptimize.process
public static boolean process( IterativeOptimization search , int maxSteps ) { for( int i = 0; i < maxSteps; i++ ) { boolean converged = step(search); if( converged ) { return search.isConverged(); } } return true; }
java
public static boolean process( IterativeOptimization search , int maxSteps ) { for( int i = 0; i < maxSteps; i++ ) { boolean converged = step(search); if( converged ) { return search.isConverged(); } } return true; }
[ "public", "static", "boolean", "process", "(", "IterativeOptimization", "search", ",", "int", "maxSteps", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxSteps", ";", "i", "++", ")", "{", "boolean", "converged", "=", "step", "(", "search...
Iterate until the line search converges or the maximum number of iterations has been exceeded. The maximum number of steps is specified. A step is defined as the number of times the optimization parameters are changed. @param search Search algorithm @param maxSteps Maximum number of steps. @return Value returned by ...
[ "Iterate", "until", "the", "line", "search", "converges", "or", "the", "maximum", "number", "of", "iterations", "has", "been", "exceeded", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/UtilOptimize.java#L38-L47
100,321
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/UtilOptimize.java
UtilOptimize.step
public static boolean step( IterativeOptimization search ) { for( int i = 0; i < 10000; i++ ) { boolean converged = search.iterate(); if( converged || !search.isUpdated() ) { return converged; } } throw new RuntimeException("After 10,000 iterations it failed to take a step! Probably a bug."); }
java
public static boolean step( IterativeOptimization search ) { for( int i = 0; i < 10000; i++ ) { boolean converged = search.iterate(); if( converged || !search.isUpdated() ) { return converged; } } throw new RuntimeException("After 10,000 iterations it failed to take a step! Probably a bug."); }
[ "public", "static", "boolean", "step", "(", "IterativeOptimization", "search", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10000", ";", "i", "++", ")", "{", "boolean", "converged", "=", "search", ".", "iterate", "(", ")", ";", "if", ...
Performs a single step by iterating until the parameters are updated. @param search Search algorithm @return Value returned by {@link IterativeOptimization#iterate}
[ "Performs", "a", "single", "step", "by", "iterating", "until", "the", "parameters", "are", "updated", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/UtilOptimize.java#L55-L63
100,322
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeMemory.java
KdTreeMemory.requestNode
public KdTree.Node requestNode() { if( unusedNodes.isEmpty() ) return new KdTree.Node(); return unusedNodes.remove( unusedNodes.size()-1); }
java
public KdTree.Node requestNode() { if( unusedNodes.isEmpty() ) return new KdTree.Node(); return unusedNodes.remove( unusedNodes.size()-1); }
[ "public", "KdTree", ".", "Node", "requestNode", "(", ")", "{", "if", "(", "unusedNodes", ".", "isEmpty", "(", ")", ")", "return", "new", "KdTree", ".", "Node", "(", ")", ";", "return", "unusedNodes", ".", "remove", "(", "unusedNodes", ".", "size", "(",...
Returns a new node. All object references can be assumed to be null. @return
[ "Returns", "a", "new", "node", ".", "All", "object", "references", "can", "be", "assumed", "to", "be", "null", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeMemory.java#L42-L46
100,323
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeMemory.java
KdTreeMemory.requestNode
public KdTree.Node requestNode(P point , int index ) { KdTree.Node n = requestNode(); n.point = point; n.index = index; n.split = -1; return n; }
java
public KdTree.Node requestNode(P point , int index ) { KdTree.Node n = requestNode(); n.point = point; n.index = index; n.split = -1; return n; }
[ "public", "KdTree", ".", "Node", "requestNode", "(", "P", "point", ",", "int", "index", ")", "{", "KdTree", ".", "Node", "n", "=", "requestNode", "(", ")", ";", "n", ".", "point", "=", "point", ";", "n", ".", "index", "=", "index", ";", "n", ".",...
Request a leaf node be returned. All data parameters will be automatically assigned appropriate values for a leaf.
[ "Request", "a", "leaf", "node", "be", "returned", ".", "All", "data", "parameters", "will", "be", "automatically", "assigned", "appropriate", "values", "for", "a", "leaf", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeMemory.java#L52-L58
100,324
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.multiply
public static Polynomial multiply( Polynomial a , Polynomial b , Polynomial result ) { int N = Math.max(0,a.size() + b.size() - 1); if( result == null ) { result = new Polynomial(N); } else { if( result.size < N ) throw new IllegalArgumentException("Unexpected length of 'result'"); result.zero(); ...
java
public static Polynomial multiply( Polynomial a , Polynomial b , Polynomial result ) { int N = Math.max(0,a.size() + b.size() - 1); if( result == null ) { result = new Polynomial(N); } else { if( result.size < N ) throw new IllegalArgumentException("Unexpected length of 'result'"); result.zero(); ...
[ "public", "static", "Polynomial", "multiply", "(", "Polynomial", "a", ",", "Polynomial", "b", ",", "Polynomial", "result", ")", "{", "int", "N", "=", "Math", ".", "max", "(", "0", ",", "a", ".", "size", "(", ")", "+", "b", ".", "size", "(", ")", ...
Multiplies the two polynomials together. @param a Polynomial @param b Polynomial @param result Optional storage parameter for the results. Must be have enough coefficients to store the results. If null a new instance is declared. @return Results of the multiplication
[ "Multiplies", "the", "two", "polynomials", "together", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L150-L172
100,325
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.add
public static Polynomial add( Polynomial a , Polynomial b , Polynomial results ) { int N = Math.max(a.size,b.size); if( results == null ) { results = new Polynomial(N); } else if( results.size < N ) { throw new IllegalArgumentException("storage for results must be at least as large as the the largest polyn...
java
public static Polynomial add( Polynomial a , Polynomial b , Polynomial results ) { int N = Math.max(a.size,b.size); if( results == null ) { results = new Polynomial(N); } else if( results.size < N ) { throw new IllegalArgumentException("storage for results must be at least as large as the the largest polyn...
[ "public", "static", "Polynomial", "add", "(", "Polynomial", "a", ",", "Polynomial", "b", ",", "Polynomial", "results", ")", "{", "int", "N", "=", "Math", ".", "max", "(", "a", ".", "size", ",", "b", ".", "size", ")", ";", "if", "(", "results", "=="...
Adds two polynomials together. The lengths of the polynomials do not need to be the zero, but the 'missing' coefficients are assumed to be zero. @param a Polynomial @param b Polynomial @param results Optional storage for resulting polynomial. If null a new instance is declared. If not null its length must be the same...
[ "Adds", "two", "polynomials", "together", ".", "The", "lengths", "of", "the", "polynomials", "do", "not", "need", "to", "be", "the", "zero", "but", "the", "missing", "coefficients", "are", "assumed", "to", "be", "zero", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L184-L212
100,326
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialOps.java
PolynomialOps.createRootFinder
public static PolynomialRoots createRootFinder( int maxCoefficients , RootFinderType which ) { switch( which ) { case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxCoefficients,-1,1e-10,200,200); return new WrapRealRootsSturm(sturm); case EVD: return new RootFinderCompanion(); def...
java
public static PolynomialRoots createRootFinder( int maxCoefficients , RootFinderType which ) { switch( which ) { case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxCoefficients,-1,1e-10,200,200); return new WrapRealRootsSturm(sturm); case EVD: return new RootFinderCompanion(); def...
[ "public", "static", "PolynomialRoots", "createRootFinder", "(", "int", "maxCoefficients", ",", "RootFinderType", "which", ")", "{", "switch", "(", "which", ")", "{", "case", "STURM", ":", "FindRealRootsSturm", "sturm", "=", "new", "FindRealRootsSturm", "(", "maxCo...
Creates different polynomial root finders. @param maxCoefficients The maximum number of coefficients that will be processed. This is the order + 1 @param which 0 = Sturm and 1 = companion matrix. @return PolynomialRoots
[ "Creates", "different", "polynomial", "root", "finders", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialOps.java#L229-L241
100,327
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/DerivativeChecker.java
DerivativeChecker.gradient
public static boolean gradient( FunctionNtoS func , FunctionNtoN gradient , double param[] , double tol ) { return gradient(func, gradient, param, tol, Math.sqrt(UtilEjml.EPS)); }
java
public static boolean gradient( FunctionNtoS func , FunctionNtoN gradient , double param[] , double tol ) { return gradient(func, gradient, param, tol, Math.sqrt(UtilEjml.EPS)); }
[ "public", "static", "boolean", "gradient", "(", "FunctionNtoS", "func", ",", "FunctionNtoN", "gradient", ",", "double", "param", "[", "]", ",", "double", "tol", ")", "{", "return", "gradient", "(", "func", ",", "gradient", ",", "param", ",", "tol", ",", ...
Compares the passed in gradient function to a numerical calculation. Comparison is done using an absolute value. @return true for within tolerance and false otherwise
[ "Compares", "the", "passed", "in", "gradient", "function", "to", "a", "numerical", "calculation", ".", "Comparison", "is", "done", "using", "an", "absolute", "value", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/DerivativeChecker.java#L232-L236
100,328
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.bracket
protected boolean bracket() { // System.out.println("------------- bracket"); // the value of alpha was passed in function.setInput(stp); if( mode != 0 ) { fp = function.computeFunction(); gp = Double.NaN; } else { mode = 1; } // check for upper bounds if( fp > valueZero + ftol * stp *derivZero...
java
protected boolean bracket() { // System.out.println("------------- bracket"); // the value of alpha was passed in function.setInput(stp); if( mode != 0 ) { fp = function.computeFunction(); gp = Double.NaN; } else { mode = 1; } // check for upper bounds if( fp > valueZero + ftol * stp *derivZero...
[ "protected", "boolean", "bracket", "(", ")", "{", "//\t\tSystem.out.println(\"------------- bracket\");", "// the value of alpha was passed in", "function", ".", "setInput", "(", "stp", ")", ";", "if", "(", "mode", "!=", "0", ")", "{", "fp", "=", "function", ".", ...
Searches for an upper bound.
[ "Searches", "for", "an", "upper", "bound", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L210-L267
100,329
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.section
protected boolean section() { // System.out.println("------------- section"); // compute the value at the new sample point double temp = stp; stp = interpolate(pLow +t2*(pHi - pLow), pHi -t3*(pHi - pLow)); updated = true; // save the previous step if( !Double.isNaN(gp)) { // needs to keep a step with a...
java
protected boolean section() { // System.out.println("------------- section"); // compute the value at the new sample point double temp = stp; stp = interpolate(pLow +t2*(pHi - pLow), pHi -t3*(pHi - pLow)); updated = true; // save the previous step if( !Double.isNaN(gp)) { // needs to keep a step with a...
[ "protected", "boolean", "section", "(", ")", "{", "//\t\tSystem.out.println(\"------------- section\");", "// compute the value at the new sample point", "double", "temp", "=", "stp", ";", "stp", "=", "interpolate", "(", "pLow", "+", "t2", "*", "(", "pHi", "-", "pLow"...
Using the found bracket for alpha it searches for a better estimate.
[ "Using", "the", "found", "bracket", "for", "alpha", "it", "searches", "for", "a", "better", "estimate", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L280-L327
100,330
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.checkSmallStep
protected boolean checkSmallStep() { double max = Math.max(stp, stprev); return( Math.abs(stp - stprev)/max < tolStep ); }
java
protected boolean checkSmallStep() { double max = Math.max(stp, stprev); return( Math.abs(stp - stprev)/max < tolStep ); }
[ "protected", "boolean", "checkSmallStep", "(", ")", "{", "double", "max", "=", "Math", ".", "max", "(", "stp", ",", "stprev", ")", ";", "return", "(", "Math", ".", "abs", "(", "stp", "-", "stprev", ")", "/", "max", "<", "tolStep", ")", ";", "}" ]
Checks to see if alpha is changing by a significant amount. If it change is too small it can get stuck in a loop\
[ "Checks", "to", "see", "if", "alpha", "is", "changing", "by", "a", "significant", "amount", ".", "If", "it", "change", "is", "too", "small", "it", "can", "get", "stuck", "in", "a", "loop", "\\" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L343-L346
100,331
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java
LineSearchFletcher86.interpolate
protected double interpolate( double boundA , double boundB ) { double alphaNew; // interpolate minimum for rapid convergence if( Double.isNaN(gp) ) { alphaNew = SearchInterpolate.quadratic(fprev, gprev, stprev, fp, stp); } else { alphaNew = SearchInterpolate.cubic2(fprev, gprev, stprev, fp, gp, stp); ...
java
protected double interpolate( double boundA , double boundB ) { double alphaNew; // interpolate minimum for rapid convergence if( Double.isNaN(gp) ) { alphaNew = SearchInterpolate.quadratic(fprev, gprev, stprev, fp, stp); } else { alphaNew = SearchInterpolate.cubic2(fprev, gprev, stprev, fp, gp, stp); ...
[ "protected", "double", "interpolate", "(", "double", "boundA", ",", "double", "boundB", ")", "{", "double", "alphaNew", ";", "// interpolate minimum for rapid convergence", "if", "(", "Double", ".", "isNaN", "(", "gp", ")", ")", "{", "alphaNew", "=", "SearchInte...
Use either quadratic of cubic interpolation to guess the minimum.
[ "Use", "either", "quadratic", "of", "cubic", "interpolation", "to", "guess", "the", "minimum", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchFletcher86.java#L351-L379
100,332
lessthanoptimal/ddogleg
benchmark/src/org/ddogleg/optimization/LineSearchEvaluator.java
LineSearchEvaluator.process
private List<Results> process( FunctionStoS f , FunctionStoS g , double ...initSteps ) { List<Results> results = new ArrayList<Results>(); for( double step : initSteps ) { results.add(performTest(f,g,step,0,Double.POSITIVE_INFINITY)); } return results; }
java
private List<Results> process( FunctionStoS f , FunctionStoS g , double ...initSteps ) { List<Results> results = new ArrayList<Results>(); for( double step : initSteps ) { results.add(performTest(f,g,step,0,Double.POSITIVE_INFINITY)); } return results; }
[ "private", "List", "<", "Results", ">", "process", "(", "FunctionStoS", "f", ",", "FunctionStoS", "g", ",", "double", "...", "initSteps", ")", "{", "List", "<", "Results", ">", "results", "=", "new", "ArrayList", "<", "Results", ">", "(", ")", ";", "fo...
Processes and compile results for the function at the specified initial steps
[ "Processes", "and", "compile", "results", "for", "the", "function", "at", "the", "specified", "initial", "steps" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/benchmark/src/org/ddogleg/optimization/LineSearchEvaluator.java#L93-L102
100,333
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/CountingSort.java
CountingSort.sort
public void sort( int data[] , int begin , int end ) { histogram.fill(0); for( int i = begin; i < end; i++ ) { histogram.data[data[i]-minValue]++; } // over wrist the input data with sorted elements int index = begin; for( int i = 0; i < histogram.size; i++ ) { int N = histogram.get(i); int value...
java
public void sort( int data[] , int begin , int end ) { histogram.fill(0); for( int i = begin; i < end; i++ ) { histogram.data[data[i]-minValue]++; } // over wrist the input data with sorted elements int index = begin; for( int i = 0; i < histogram.size; i++ ) { int N = histogram.get(i); int value...
[ "public", "void", "sort", "(", "int", "data", "[", "]", ",", "int", "begin", ",", "int", "end", ")", "{", "histogram", ".", "fill", "(", "0", ")", ";", "for", "(", "int", "i", "=", "begin", ";", "i", "<", "end", ";", "i", "++", ")", "{", "h...
Sorts the data in the array. @param data Data which is to be sorted. Sorted data is written back into this same array @param begin First element to be sorted (inclusive) @param end Last element to be sorted (exclusive)
[ "Sorts", "the", "data", "in", "the", "array", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/CountingSort.java#L64-L80
100,334
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/CountingSort.java
CountingSort.sort
public void sort( int input[] , int startIndex ,int output[] , int startOutput , int length ) { histogram.fill(0); for( int i = 0; i < length; i++ ) { histogram.data[input[i+startIndex]-minValue]++; } // over wrist the input data with sorted elements int index = startOutput; for( int i = 0; i < histogr...
java
public void sort( int input[] , int startIndex ,int output[] , int startOutput , int length ) { histogram.fill(0); for( int i = 0; i < length; i++ ) { histogram.data[input[i+startIndex]-minValue]++; } // over wrist the input data with sorted elements int index = startOutput; for( int i = 0; i < histogr...
[ "public", "void", "sort", "(", "int", "input", "[", "]", ",", "int", "startIndex", ",", "int", "output", "[", "]", ",", "int", "startOutput", ",", "int", "length", ")", "{", "histogram", ".", "fill", "(", "0", ")", ";", "for", "(", "int", "i", "=...
Sort routine which does not modify the input array. Input and output arrays can be the same instance. @param input (Input) Data which is to be sorted. Not modified. @param startIndex First element in input list @param output (Output) Sorted data. Modified. @param length Number of elements
[ "Sort", "routine", "which", "does", "not", "modify", "the", "input", "array", ".", "Input", "and", "output", "arrays", "can", "be", "the", "same", "instance", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/CountingSort.java#L90-L106
100,335
lessthanoptimal/ddogleg
examples/src/org/ddogleg/example/DistanceFromLine.java
DistanceFromLine.computeDistance
@Override public void computeDistance(List<Point2D> obs, double[] distance) { for( int i = 0; i < obs.size(); i++ ) { distance[i] = computeDistance(obs.get(i)); } }
java
@Override public void computeDistance(List<Point2D> obs, double[] distance) { for( int i = 0; i < obs.size(); i++ ) { distance[i] = computeDistance(obs.get(i)); } }
[ "@", "Override", "public", "void", "computeDistance", "(", "List", "<", "Point2D", ">", "obs", ",", "double", "[", "]", "distance", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "obs", ".", "size", "(", ")", ";", "i", "++", ")", "{...
There are some situations where processing everything as a list can speed things up a lot. This is not one of them.
[ "There", "are", "some", "situations", "where", "processing", "everything", "as", "a", "list", "can", "speed", "things", "up", "a", "lot", ".", "This", "is", "not", "one", "of", "them", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/examples/src/org/ddogleg/example/DistanceFromLine.java#L67-L72
100,336
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/StraightInsertionSort.java
StraightInsertionSort.sort
public static void sort( double[] data ) { int i=0,j; final int n = data.length; double a; // by doing the ugly exception catching it was 13% faster // on data set of 100000 try { for( j =1; ; j++ ) { a=data[j]; try { for( i=j; data[i-1] > a;i-- ) { data[i]=data[i-1]; } }cat...
java
public static void sort( double[] data ) { int i=0,j; final int n = data.length; double a; // by doing the ugly exception catching it was 13% faster // on data set of 100000 try { for( j =1; ; j++ ) { a=data[j]; try { for( i=j; data[i-1] > a;i-- ) { data[i]=data[i-1]; } }cat...
[ "public", "static", "void", "sort", "(", "double", "[", "]", "data", ")", "{", "int", "i", "=", "0", ",", "j", ";", "final", "int", "n", "=", "data", ".", "length", ";", "double", "a", ";", "// by doing the ugly exception catching it was 13% faster", "// o...
Sorts data into ascending order
[ "Sorts", "data", "into", "ascending", "order" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/StraightInsertionSort.java#L35-L54
100,337
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.computeBranch
protected KdTree.Node computeBranch(List<P> points, GrowQueue_I32 indexes) { // declare storage for the split data List<P> left = new ArrayList<>(points.size()/2); List<P> right = new ArrayList<>(points.size()/2); GrowQueue_I32 leftIndexes,rightIndexes; if( indexes == null ) { leftIndexes = null; rightIn...
java
protected KdTree.Node computeBranch(List<P> points, GrowQueue_I32 indexes) { // declare storage for the split data List<P> left = new ArrayList<>(points.size()/2); List<P> right = new ArrayList<>(points.size()/2); GrowQueue_I32 leftIndexes,rightIndexes; if( indexes == null ) { leftIndexes = null; rightIn...
[ "protected", "KdTree", ".", "Node", "computeBranch", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "// declare storage for the split data", "List", "<", "P", ">", "left", "=", "new", "ArrayList", "<>", "(", "points", ".", "...
Given the data inside this particular node, select a point for the node and compute the node's children @return The node associated with this region
[ "Given", "the", "data", "inside", "this", "particular", "node", "select", "a", "point", "for", "the", "node", "and", "compute", "the", "node", "s", "children" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L99-L130
100,338
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.computeChild
protected KdTree.Node computeChild(List<P> points , GrowQueue_I32 indexes ) { if( points.size() == 0 ) return null; if( points.size() == 1 ) { return createLeaf(points,indexes); } else { return computeBranch(points,indexes); } }
java
protected KdTree.Node computeChild(List<P> points , GrowQueue_I32 indexes ) { if( points.size() == 0 ) return null; if( points.size() == 1 ) { return createLeaf(points,indexes); } else { return computeBranch(points,indexes); } }
[ "protected", "KdTree", ".", "Node", "computeChild", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "if", "(", "points", ".", "size", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "points", ".", "size", ...
Creates a child by checking to see if it is a leaf or branch.
[ "Creates", "a", "child", "by", "checking", "to", "see", "if", "it", "is", "a", "leaf", "or", "branch", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L135-L144
100,339
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/KdTreeConstructor.java
KdTreeConstructor.createLeaf
private KdTree.Node createLeaf(List<P> points , GrowQueue_I32 indexes ) { int index = indexes == null ? -1 : indexes.get(0); return memory.requestNode(points.get(0),index); }
java
private KdTree.Node createLeaf(List<P> points , GrowQueue_I32 indexes ) { int index = indexes == null ? -1 : indexes.get(0); return memory.requestNode(points.get(0),index); }
[ "private", "KdTree", ".", "Node", "createLeaf", "(", "List", "<", "P", ">", "points", ",", "GrowQueue_I32", "indexes", ")", "{", "int", "index", "=", "indexes", "==", "null", "?", "-", "1", ":", "indexes", ".", "get", "(", "0", ")", ";", "return", ...
Convenient function for creating a leaf node
[ "Convenient", "function", "for", "creating", "a", "leaf", "node" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/KdTreeConstructor.java#L149-L152
100,340
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.remove
public void remove( int first , int last ) { if( last < first ) throw new IllegalArgumentException("first <= last"); if( last >= size ) throw new IllegalArgumentException("last must be less than the max size"); int delta = last-first+1; for( int i = last+1; i < size; i++ ) { data[i-delta] = data[i]; ...
java
public void remove( int first , int last ) { if( last < first ) throw new IllegalArgumentException("first <= last"); if( last >= size ) throw new IllegalArgumentException("last must be less than the max size"); int delta = last-first+1; for( int i = last+1; i < size; i++ ) { data[i-delta] = data[i]; ...
[ "public", "void", "remove", "(", "int", "first", ",", "int", "last", ")", "{", "if", "(", "last", "<", "first", ")", "throw", "new", "IllegalArgumentException", "(", "\"first <= last\"", ")", ";", "if", "(", "last", ">=", "size", ")", "throw", "new", "...
Removes elements from the list starting at 'first' and ending at 'last' @param first First index you wish to remove. Inclusive. @param last Last index you wish to remove. Inclusive.
[ "Removes", "elements", "from", "the", "list", "starting", "at", "first", "and", "ending", "at", "last" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L176-L187
100,341
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.printHex
public void printHex() { System.out.print("[ "); for (int i = 0; i < size; i++) { System.out.printf("0x%02X ",data[i]); } System.out.print("]"); }
java
public void printHex() { System.out.print("[ "); for (int i = 0; i < size; i++) { System.out.printf("0x%02X ",data[i]); } System.out.print("]"); }
[ "public", "void", "printHex", "(", ")", "{", "System", ".", "out", ".", "print", "(", "\"[ \"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "System", ".", "out", ".", "printf", "(", "\"0x%02X \""...
Prints the queue to stdout as a hex array
[ "Prints", "the", "queue", "to", "stdout", "as", "a", "hex", "array" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L262-L268
100,342
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_I8.java
GrowQueue_I8.indexOf
public int indexOf( byte value ) { for (int i = 0; i < size; i++) { if( data[i] == value ) return i; } return -1; }
java
public int indexOf( byte value ) { for (int i = 0; i < size; i++) { if( data[i] == value ) return i; } return -1; }
[ "public", "int", "indexOf", "(", "byte", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "if", "(", "data", "[", "i", "]", "==", "value", ")", "return", "i", ";", "}", "return", "-", "1"...
Returns the index of the first element with the specified 'value'. return -1 if it wasn't found @param value Value to search for @return index or -1 if it's not in the list
[ "Returns", "the", "index", "of", "the", "first", "element", "with", "the", "specified", "value", ".", "return", "-", "1", "if", "it", "wasn", "t", "found" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I8.java#L291-L297
100,343
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.computeRange
public void computeRange( SortableParameter_F32 input[] , int start , int length ) { if( length == 0 ) { divisor = 0; return; } float min,max; min = max = input[start].sortValue; for( int i = 1; i < length; i++ ) { float val = input[start+i].sortValue; if( val < min ) min = val; else if(...
java
public void computeRange( SortableParameter_F32 input[] , int start , int length ) { if( length == 0 ) { divisor = 0; return; } float min,max; min = max = input[start].sortValue; for( int i = 1; i < length; i++ ) { float val = input[start+i].sortValue; if( val < min ) min = val; else if(...
[ "public", "void", "computeRange", "(", "SortableParameter_F32", "input", "[", "]", ",", "int", "start", ",", "int", "length", ")", "{", "if", "(", "length", "==", "0", ")", "{", "divisor", "=", "0", ";", "return", ";", "}", "float", "min", ",", "max"...
Examines the list and computes the range from it
[ "Examines", "the", "list", "and", "computes", "the", "range", "from", "it" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L95-L114
100,344
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.sortIndex
public void sortIndex( float input[] , int start , int length , int indexes[] ) { for( int i = 0; i < length; i++ ) indexes[i] = i; for( int i = 0; i < histIndexes.size; i++ ) { histIndexes.get(i).reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; int discretized = (int)((inp...
java
public void sortIndex( float input[] , int start , int length , int indexes[] ) { for( int i = 0; i < length; i++ ) indexes[i] = i; for( int i = 0; i < histIndexes.size; i++ ) { histIndexes.get(i).reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; int discretized = (int)((inp...
[ "public", "void", "sortIndex", "(", "float", "input", "[", "]", ",", "int", "start", ",", "int", "length", ",", "int", "indexes", "[", "]", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "indexes", "["...
Sort routine which does not modify the input array and instead maintains a list of indexes. @param input (Input) Data which is to be sorted. Not modified. @param start First element in input list @param length Length of the input list @param indexes Number of elements
[ "Sort", "routine", "which", "does", "not", "modify", "the", "input", "array", "and", "instead", "maintains", "a", "list", "of", "indexes", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L124-L146
100,345
lessthanoptimal/ddogleg
src/org/ddogleg/sorting/ApproximateSort_F32.java
ApproximateSort_F32.sortObject
public void sortObject( SortableParameter_F32 input[] , int start , int length ) { for( int i = 0; i < histIndexes.size; i++ ) { histObjs[i].reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; SortableParameter_F32 p = input[indexInput]; int discretized = (int)((p.sortValue-minV...
java
public void sortObject( SortableParameter_F32 input[] , int start , int length ) { for( int i = 0; i < histIndexes.size; i++ ) { histObjs[i].reset(); } for( int i = 0; i < length; i++ ) { int indexInput = i+start; SortableParameter_F32 p = input[indexInput]; int discretized = (int)((p.sortValue-minV...
[ "public", "void", "sortObject", "(", "SortableParameter_F32", "input", "[", "]", ",", "int", "start", ",", "int", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "histIndexes", ".", "size", ";", "i", "++", ")", "{", "histObjs", ...
Sorts the input list @param input (Input) Data which is to be sorted. Not modified. @param start First element in input list @param length Length of the input list
[ "Sorts", "the", "input", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/sorting/ApproximateSort_F32.java#L155-L176
100,346
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java
KdTreeSearchBestBinFirst.searchNode
protected void searchNode(P target, KdTree.Node n) { while( n != null) { checkBestDistance(n, target); if( n.isLeaf() ) break; // select the most promising branch to investigate first KdTree.Node nearer,further; double splitValue = distance.valueAt( (P)n.point , n.split ); if( distance.value...
java
protected void searchNode(P target, KdTree.Node n) { while( n != null) { checkBestDistance(n, target); if( n.isLeaf() ) break; // select the most promising branch to investigate first KdTree.Node nearer,further; double splitValue = distance.valueAt( (P)n.point , n.split ); if( distance.value...
[ "protected", "void", "searchNode", "(", "P", "target", ",", "KdTree", ".", "Node", "n", ")", "{", "while", "(", "n", "!=", "null", ")", "{", "checkBestDistance", "(", "n", ",", "target", ")", ";", "if", "(", "n", ".", "isLeaf", "(", ")", ")", "br...
Traverse a node down to a leaf. Unexplored branches are added to the priority queue.
[ "Traverse", "a", "node", "down", "to", "a", "leaf", ".", "Unexplored", "branches", "are", "added", "to", "the", "priority", "queue", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java#L136-L164
100,347
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java
KdTreeSearchBestBinFirst.addToQueue
protected void addToQueue(double closestDistanceSq , KdTree.Node node , P target ) { if( !node.isLeaf() ) { Helper h; if( unused.isEmpty() ) { h = new Helper(); } else { h = unused.remove( unused.size()-1 ); } h.closestPossibleSq = closestDistanceSq; h.node = node; queue.add(h); } el...
java
protected void addToQueue(double closestDistanceSq , KdTree.Node node , P target ) { if( !node.isLeaf() ) { Helper h; if( unused.isEmpty() ) { h = new Helper(); } else { h = unused.remove( unused.size()-1 ); } h.closestPossibleSq = closestDistanceSq; h.node = node; queue.add(h); } el...
[ "protected", "void", "addToQueue", "(", "double", "closestDistanceSq", ",", "KdTree", ".", "Node", "node", ",", "P", "target", ")", "{", "if", "(", "!", "node", ".", "isLeaf", "(", ")", ")", "{", "Helper", "h", ";", "if", "(", "unused", ".", "isEmpty...
Adds a node to the priority queue. @param closestDistanceSq The closest distance that a point in the region could possibly be target
[ "Adds", "a", "node", "to", "the", "priority", "queue", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchBestBinFirst.java#L171-L188
100,348
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java
InitializePlusPlus.selectNextSeed
protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); do...
java
protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); do...
[ "protected", "final", "double", "[", "]", "selectNextSeed", "(", "List", "<", "double", "[", "]", ">", "points", ",", "double", "target", ")", "{", "// this won't select previously selected points because the distance will be zero", "// If the distance is zero it will simply ...
Randomly selects the next seed. The chance of a seed is based upon its distance from the closest cluster. Larger distances mean more likely. @param points List of all the points @param target Number from 0 to 1, inclusive @return Index of the selected seed
[ "Randomly", "selects", "the", "next", "seed", ".", "The", "chance", "of", "a", "seed", "is", "based", "upon", "its", "distance", "from", "the", "closest", "cluster", ".", "Larger", "distances", "mean", "more", "likely", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java#L94-L105
100,349
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java
InitializePlusPlus.updateDistances
protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; tot...
java
protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; tot...
[ "protected", "final", "void", "updateDistances", "(", "List", "<", "double", "[", "]", ">", "points", ",", "double", "[", "]", "clusterNew", ")", "{", "totalDistance", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "distance", ".", ...
Updates the list of distances from a point to the closest cluster. Update list of total distances
[ "Updates", "the", "list", "of", "distances", "from", "a", "point", "to", "the", "closest", "cluster", ".", "Update", "list", "of", "total", "distances" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/InitializePlusPlus.java#L110-L122
100,350
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/gmm/GaussianLikelihoodManager.java
GaussianLikelihoodManager.precomputeAll
public void precomputeAll() { precomputes.resize(mixtures.size()); for (int i = 0; i < precomputes.size; i++) { precomputes.get(i).setGaussian(mixtures.get(i)); } }
java
public void precomputeAll() { precomputes.resize(mixtures.size()); for (int i = 0; i < precomputes.size; i++) { precomputes.get(i).setGaussian(mixtures.get(i)); } }
[ "public", "void", "precomputeAll", "(", ")", "{", "precomputes", ".", "resize", "(", "mixtures", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "precomputes", ".", "size", ";", "i", "++", ")", "{", "precomputes", ...
Precomputes likelihood for all the mixtures
[ "Precomputes", "likelihood", "for", "all", "the", "mixtures" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/GaussianLikelihoodManager.java#L69-L74
100,351
lessthanoptimal/ddogleg
src/org/ddogleg/util/PrimitiveArrays.java
PrimitiveArrays.fillCounting
public static void fillCounting(int[] array , int offset, int length ) { for (int i = 0; i < length; i++) { array[i+offset] = i; } }
java
public static void fillCounting(int[] array , int offset, int length ) { for (int i = 0; i < length; i++) { array[i+offset] = i; } }
[ "public", "static", "void", "fillCounting", "(", "int", "[", "]", "array", ",", "int", "offset", ",", "int", "length", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "array", "[", "i", "+", "offse...
Sets each element within range to a number counting up
[ "Sets", "each", "element", "within", "range", "to", "a", "number", "counting", "up" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/util/PrimitiveArrays.java#L33-L37
100,352
lessthanoptimal/ddogleg
src/org/ddogleg/util/PrimitiveArrays.java
PrimitiveArrays.shuffle
public static void shuffle( byte []array , int offset , int length , Random rand ) { for (int i = 0; i < length; i++) { int src = rand.nextInt(length-i); byte tmp = array[offset+src+i]; array[offset+src+i]=array[offset+i]; array[offset+i] = tmp; } }
java
public static void shuffle( byte []array , int offset , int length , Random rand ) { for (int i = 0; i < length; i++) { int src = rand.nextInt(length-i); byte tmp = array[offset+src+i]; array[offset+src+i]=array[offset+i]; array[offset+i] = tmp; } }
[ "public", "static", "void", "shuffle", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "int", "length", ",", "Random", "rand", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "int", "src...
Randomly shuffle the array
[ "Randomly", "shuffle", "the", "array" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/util/PrimitiveArrays.java#L48-L55
100,353
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.setConvergence
public LineSearchMore94 setConvergence(double ftol, double gtol, double xtol) { if( ftol < 0 ) throw new IllegalArgumentException("ftol must be >= 0 "); if( gtol < 0 ) throw new IllegalArgumentException("gtol must be >= 0 "); if( xtol < 0 ) throw new IllegalArgumentException("xtol must be >= 0 "); thi...
java
public LineSearchMore94 setConvergence(double ftol, double gtol, double xtol) { if( ftol < 0 ) throw new IllegalArgumentException("ftol must be >= 0 "); if( gtol < 0 ) throw new IllegalArgumentException("gtol must be >= 0 "); if( xtol < 0 ) throw new IllegalArgumentException("xtol must be >= 0 "); thi...
[ "public", "LineSearchMore94", "setConvergence", "(", "double", "ftol", ",", "double", "gtol", ",", "double", "xtol", ")", "{", "if", "(", "ftol", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"ftol must be >= 0 \"", ")", ";", "if", "(", "...
Configures the line search. @param ftol Tolerance for sufficient decrease. ftol {@code >} 0. Smaller value for loose tolerance. Try 1e-4 @param gtol Tolerance for curvature condition. gtol &ge; 0. Larger value for loose tolerance. Try 0.9 @param xtol Relative tolerance for acceptable step. xtol &ge; 0. Larger value ...
[ "Configures", "the", "line", "search", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L124-L136
100,354
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.dcstep
private void dcstep() { double sgnd = gp*Math.signum(gx); // the new step double stpf; if( fp > fx ) { stpf = handleCase1(); } else if( sgnd < 0 ) { stpf = handleCase2(); } else if( Math.abs(gp) < Math.abs(gx) ) { stpf = handleCase3(); } else { stpf = handleCase4(); } // update the brac...
java
private void dcstep() { double sgnd = gp*Math.signum(gx); // the new step double stpf; if( fp > fx ) { stpf = handleCase1(); } else if( sgnd < 0 ) { stpf = handleCase2(); } else if( Math.abs(gp) < Math.abs(gx) ) { stpf = handleCase3(); } else { stpf = handleCase4(); } // update the brac...
[ "private", "void", "dcstep", "(", ")", "{", "double", "sgnd", "=", "gp", "*", "Math", ".", "signum", "(", "gx", ")", ";", "// the new step", "double", "stpf", ";", "if", "(", "fp", ">", "fx", ")", "{", "stpf", "=", "handleCase1", "(", ")", ";", "...
Computes the new step and updates fx,fy,gx,dy.
[ "Computes", "the", "new", "step", "and", "updates", "fx", "fy", "gx", "dy", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L311-L347
100,355
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase1
private double handleCase1() { double stpc = SearchInterpolate.cubic2(fx, gx, stx, fp, gp, stp); double stpq = SearchInterpolate.quadratic(fx,gx,stx,fp,stp); // If the cubic step is closer to stx than the quadratic step take that bracket = true; if( Math.abs(stpc-stx) < Math.abs(stpq-stx)) { return stpc;...
java
private double handleCase1() { double stpc = SearchInterpolate.cubic2(fx, gx, stx, fp, gp, stp); double stpq = SearchInterpolate.quadratic(fx,gx,stx,fp,stp); // If the cubic step is closer to stx than the quadratic step take that bracket = true; if( Math.abs(stpc-stx) < Math.abs(stpq-stx)) { return stpc;...
[ "private", "double", "handleCase1", "(", ")", "{", "double", "stpc", "=", "SearchInterpolate", ".", "cubic2", "(", "fx", ",", "gx", ",", "stx", ",", "fp", ",", "gp", ",", "stp", ")", ";", "double", "stpq", "=", "SearchInterpolate", ".", "quadratic", "(...
stp has a higher value than stx. The minimum must be between these two values. Pick a point which is close to stx since it has a lower value. @return The new step.
[ "stp", "has", "a", "higher", "value", "than", "stx", ".", "The", "minimum", "must", "be", "between", "these", "two", "values", ".", "Pick", "a", "point", "which", "is", "close", "to", "stx", "since", "it", "has", "a", "lower", "value", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L355-L368
100,356
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase2
private double handleCase2() { double stpc = SearchInterpolate.cubic2(fp, gp, stp, fx, gx, stx); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); // use which ever is closest to stp since it is lower than stx bracket = true; if( Math.abs(stpc - stp) > Math.abs(stpq - stp)) { return stpc; } els...
java
private double handleCase2() { double stpc = SearchInterpolate.cubic2(fp, gp, stp, fx, gx, stx); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); // use which ever is closest to stp since it is lower than stx bracket = true; if( Math.abs(stpc - stp) > Math.abs(stpq - stp)) { return stpc; } els...
[ "private", "double", "handleCase2", "(", ")", "{", "double", "stpc", "=", "SearchInterpolate", ".", "cubic2", "(", "fp", ",", "gp", ",", "stp", ",", "fx", ",", "gx", ",", "stx", ")", ";", "double", "stpq", "=", "SearchInterpolate", ".", "quadratic2", "...
The sign of the derivative has swapped, indicating that the function is on the other side of the dip and that a bracket has been found. @return The new step.
[ "The", "sign", "of", "the", "derivative", "has", "swapped", "indicating", "that", "the", "function", "is", "on", "the", "other", "side", "of", "the", "dip", "and", "that", "a", "bracket", "has", "been", "found", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L376-L387
100,357
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase3
private double handleCase3() { double stpf; // use cubic interpolation only if it is safe double stpc = SearchInterpolate.cubicSafe(fp, gp, stp, fx, gx, stx, stmin, stmax); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); if( bracket ) { // Use which ever step is closer to stp if( Math.abs(st...
java
private double handleCase3() { double stpf; // use cubic interpolation only if it is safe double stpc = SearchInterpolate.cubicSafe(fp, gp, stp, fx, gx, stx, stmin, stmax); double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx); if( bracket ) { // Use which ever step is closer to stp if( Math.abs(st...
[ "private", "double", "handleCase3", "(", ")", "{", "double", "stpf", ";", "// use cubic interpolation only if it is safe", "double", "stpc", "=", "SearchInterpolate", ".", "cubicSafe", "(", "fp", ",", "gp", ",", "stp", ",", "fx", ",", "gx", ",", "stx", ",", ...
The derivative at stp has a smaller magnitude than at stx and is likely to be closer to the minimum. However there are special cases that need to be dealt with here. @return The new step.
[ "The", "derivative", "at", "stp", "has", "a", "smaller", "magnitude", "than", "at", "stx", "and", "is", "likely", "to", "be", "closer", "to", "the", "minimum", ".", "However", "there", "are", "special", "cases", "that", "need", "to", "be", "dealt", "with...
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L395-L424
100,358
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java
LineSearchMore94.handleCase4
private double handleCase4() { if( bracket ) { return SearchInterpolate.cubic2(fp, gp, stp, fy, gy, sty); } else if( stp > stx ) { return stmax; // see comment in case 3 about stmax and stmin } else { return stmin; } }
java
private double handleCase4() { if( bracket ) { return SearchInterpolate.cubic2(fp, gp, stp, fy, gy, sty); } else if( stp > stx ) { return stmax; // see comment in case 3 about stmax and stmin } else { return stmin; } }
[ "private", "double", "handleCase4", "(", ")", "{", "if", "(", "bracket", ")", "{", "return", "SearchInterpolate", ".", "cubic2", "(", "fp", ",", "gp", ",", "stp", ",", "fy", ",", "gy", ",", "sty", ")", ";", "}", "else", "if", "(", "stp", ">", "st...
Lower function value. On the same side of the dip because the gradients have the same sign. The magnitude of the derivative did not decrease. @return The new step.
[ "Lower", "function", "value", ".", "On", "the", "same", "side", "of", "the", "dip", "because", "the", "gradients", "have", "the", "same", "sign", ".", "The", "magnitude", "of", "the", "derivative", "did", "not", "decrease", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/LineSearchMore94.java#L432-L440
100,359
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/AxisSplitterMedian.java
AxisSplitterMedian.computeAxisVariance
private void computeAxisVariance(List<P> points) { int numPoints = points.size(); for( int i = 0; i < N; i++ ) { mean[i] = 0; var[i] = 0; } // compute the mean for( int i = 0; i < numPoints; i++ ) { P p = points.get(i); for( int j = 0; j < N; j++ ) { mean[j] += distance.valueAt(p,j); } ...
java
private void computeAxisVariance(List<P> points) { int numPoints = points.size(); for( int i = 0; i < N; i++ ) { mean[i] = 0; var[i] = 0; } // compute the mean for( int i = 0; i < numPoints; i++ ) { P p = points.get(i); for( int j = 0; j < N; j++ ) { mean[j] += distance.valueAt(p,j); } ...
[ "private", "void", "computeAxisVariance", "(", "List", "<", "P", ">", "points", ")", "{", "int", "numPoints", "=", "points", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "mean", "["...
Select the maximum variance as the split
[ "Select", "the", "maximum", "variance", "as", "the", "split" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/AxisSplitterMedian.java#L145-L175
100,360
lessthanoptimal/ddogleg
src/org/ddogleg/nn/alg/AxisSplitterMedian.java
AxisSplitterMedian.quickSelect
private void quickSelect(List<P> points, int splitAxis, int medianNum) { int numPoints = points.size(); if( tmp.length < numPoints ) { tmp = new double[numPoints]; indexes = new int[ numPoints ]; } for( int i = 0; i < numPoints; i++ ) { tmp[i] = distance.valueAt(points.get(i),splitAxis); } QuickS...
java
private void quickSelect(List<P> points, int splitAxis, int medianNum) { int numPoints = points.size(); if( tmp.length < numPoints ) { tmp = new double[numPoints]; indexes = new int[ numPoints ]; } for( int i = 0; i < numPoints; i++ ) { tmp[i] = distance.valueAt(points.get(i),splitAxis); } QuickS...
[ "private", "void", "quickSelect", "(", "List", "<", "P", ">", "points", ",", "int", "splitAxis", ",", "int", "medianNum", ")", "{", "int", "numPoints", "=", "points", ".", "size", "(", ")", ";", "if", "(", "tmp", ".", "length", "<", "numPoints", ")",...
Uses quick-select to find the median value
[ "Uses", "quick", "-", "select", "to", "find", "the", "median", "value" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/AxisSplitterMedian.java#L180-L192
100,361
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.init
public void init( List<T> list , int bucketSize ) { if( list.size() < bucketSize ) { throw new RuntimeException("There needs to be more than or equal to elements in the 'list' that there are in the bucket"); } this.k = bucketSize; this.c = bucketSize - 1; N = list.size(); bins = new int[ bucketSize ]; ...
java
public void init( List<T> list , int bucketSize ) { if( list.size() < bucketSize ) { throw new RuntimeException("There needs to be more than or equal to elements in the 'list' that there are in the bucket"); } this.k = bucketSize; this.c = bucketSize - 1; N = list.size(); bins = new int[ bucketSize ]; ...
[ "public", "void", "init", "(", "List", "<", "T", ">", "list", ",", "int", "bucketSize", ")", "{", "if", "(", "list", ".", "size", "(", ")", "<", "bucketSize", ")", "{", "throw", "new", "RuntimeException", "(", "\"There needs to be more than or equal to eleme...
Initialize with a new list and bucket size @param list List which is to be symbols @param bucketSize Size of the bucket
[ "Initialize", "with", "a", "new", "list", "and", "bucket", "size" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L95-L112
100,362
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.next
public boolean next() { if( state == 2 ) return false; else state = 1; bins[c]++; if( bins[c] >= N ) { boolean allgood = false; for( int i = c-1; i >= 0; i-- ) { bins[i]++; if( bins[i] <= (N-(k-i)) ) { allgood = true; for( int j = i + 1; j < k; j++ ) { bins[j] = bins[j-1]...
java
public boolean next() { if( state == 2 ) return false; else state = 1; bins[c]++; if( bins[c] >= N ) { boolean allgood = false; for( int i = c-1; i >= 0; i-- ) { bins[i]++; if( bins[i] <= (N-(k-i)) ) { allgood = true; for( int j = i + 1; j < k; j++ ) { bins[j] = bins[j-1]...
[ "public", "boolean", "next", "(", ")", "{", "if", "(", "state", "==", "2", ")", "return", "false", ";", "else", "state", "=", "1", ";", "bins", "[", "c", "]", "++", ";", "if", "(", "bins", "[", "c", "]", ">=", "N", ")", "{", "boolean", "allgo...
This will shuffle the elements in and out of the bins. When all combinations have been exhausted an ExhaustedException will be thrown. @return true if the next combination was successfully found or false is it has been exhausted
[ "This", "will", "shuffle", "the", "elements", "in", "and", "out", "of", "the", "bins", ".", "When", "all", "combinations", "have", "been", "exhausted", "an", "ExhaustedException", "will", "be", "thrown", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L121-L155
100,363
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.getBucket
public List<T> getBucket(List<T> storage) { if( storage == null ) storage = new ArrayList<T>(); else storage.clear(); for( int i = 0; i < bins.length; i++ ) { storage.add( a.get( bins[i] ) ); } return storage; }
java
public List<T> getBucket(List<T> storage) { if( storage == null ) storage = new ArrayList<T>(); else storage.clear(); for( int i = 0; i < bins.length; i++ ) { storage.add( a.get( bins[i] ) ); } return storage; }
[ "public", "List", "<", "T", ">", "getBucket", "(", "List", "<", "T", ">", "storage", ")", "{", "if", "(", "storage", "==", "null", ")", "storage", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "else", "storage", ".", "clear", "(", ")", ...
Extracts the entire bucket. Will add elements to the provided list or create a new one @param storage Optional storage. If null a list is created. clear() is automatically called. @return List containing the bucket
[ "Extracts", "the", "entire", "bucket", ".", "Will", "add", "elements", "to", "the", "provided", "list", "or", "create", "a", "new", "one" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L236-L248
100,364
lessthanoptimal/ddogleg
src/org/ddogleg/combinatorics/Combinations.java
Combinations.getOutside
public List<T> getOutside( List<T> storage ) { if( storage == null ) { storage = new ArrayList<T>(); } else { storage.clear(); } storage.addAll(a); // bins specifies elements in order of first in 'a' to last for( int i = bins.length-1; i >= 0; i-- ) { storage.remove(bins[i]); } return stor...
java
public List<T> getOutside( List<T> storage ) { if( storage == null ) { storage = new ArrayList<T>(); } else { storage.clear(); } storage.addAll(a); // bins specifies elements in order of first in 'a' to last for( int i = bins.length-1; i >= 0; i-- ) { storage.remove(bins[i]); } return stor...
[ "public", "List", "<", "T", ">", "getOutside", "(", "List", "<", "T", ">", "storage", ")", "{", "if", "(", "storage", "==", "null", ")", "{", "storage", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "}", "else", "{", "storage", ".", "c...
This returns all the items that are not currently inside the bucket @param storage Optional storage. If null a list is created. clear() is automatically called. @return List containing the bucket
[ "This", "returns", "all", "the", "items", "that", "are", "not", "currently", "inside", "the", "bucket" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Combinations.java#L256-L272
100,365
lessthanoptimal/ddogleg
src/org/ddogleg/fitting/modelset/distance/FitByMedianStatistics.java
FitByMedianStatistics.prune
@Override public void prune() { Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { iter.next(); if (origErrors[index++] >= pruneVal) { iter.remove(); } } }
java
@Override public void prune() { Iterator<PointIndex<Point>> iter = allPoints.iterator(); int index = 0; while( iter.hasNext() ) { iter.next(); if (origErrors[index++] >= pruneVal) { iter.remove(); } } }
[ "@", "Override", "public", "void", "prune", "(", ")", "{", "Iterator", "<", "PointIndex", "<", "Point", ">>", "iter", "=", "allPoints", ".", "iterator", "(", ")", ";", "int", "index", "=", "0", ";", "while", "(", "iter", ".", "hasNext", "(", ")", "...
Removes all samples which have an error larger than the specified percentile error.
[ "Removes", "all", "samples", "which", "have", "an", "error", "larger", "than", "the", "specified", "percentile", "error", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/distance/FitByMedianStatistics.java#L100-L110
100,366
lessthanoptimal/ddogleg
src/org/ddogleg/solver/PolynomialSolver.java
PolynomialSolver.createRootFinder
public static PolynomialRoots createRootFinder( RootFinderType type , int maxDegree ) { switch ( type ) { case EVD: return new RootFinderCompanion(); case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxDegree,-1,1e-10,30,20); return new WrapRealRootsSturm(sturm); } throw new Illeg...
java
public static PolynomialRoots createRootFinder( RootFinderType type , int maxDegree ) { switch ( type ) { case EVD: return new RootFinderCompanion(); case STURM: FindRealRootsSturm sturm = new FindRealRootsSturm(maxDegree,-1,1e-10,30,20); return new WrapRealRootsSturm(sturm); } throw new Illeg...
[ "public", "static", "PolynomialRoots", "createRootFinder", "(", "RootFinderType", "type", ",", "int", "maxDegree", ")", "{", "switch", "(", "type", ")", "{", "case", "EVD", ":", "return", "new", "RootFinderCompanion", "(", ")", ";", "case", "STURM", ":", "Fi...
Creates a generic polynomial root finding class which will return all real or all real and complex roots depending on the algorithm selected. @param type Which algorithm is to be returned. @param maxDegree Maximum degree of the polynomial being considered. @return Root finding algorithm.
[ "Creates", "a", "generic", "polynomial", "root", "finding", "class", "which", "will", "return", "all", "real", "or", "all", "real", "and", "complex", "roots", "depending", "on", "the", "algorithm", "selected", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/PolynomialSolver.java#L44-L55
100,367
lessthanoptimal/ddogleg
src/org/ddogleg/struct/CircularQueue.java
CircularQueue.grow
public T grow() { if( size >= data.length) { T a = createInstance(); add(a); return a; } else { T a = data[(start+size)%data.length]; if( a == null ) { data[(start+size)%data.length] = a = createInstance(); } size++; return a; } }
java
public T grow() { if( size >= data.length) { T a = createInstance(); add(a); return a; } else { T a = data[(start+size)%data.length]; if( a == null ) { data[(start+size)%data.length] = a = createInstance(); } size++; return a; } }
[ "public", "T", "grow", "(", ")", "{", "if", "(", "size", ">=", "data", ".", "length", ")", "{", "T", "a", "=", "createInstance", "(", ")", ";", "add", "(", "a", ")", ";", "return", "a", ";", "}", "else", "{", "T", "a", "=", "data", "[", "("...
Adds a new element to the end of the list and returns it. If the inner array isn't large enough then it will grow. @return instance at the tail
[ "Adds", "a", "new", "element", "to", "the", "end", "of", "the", "list", "and", "returns", "it", ".", "If", "the", "inner", "array", "isn", "t", "large", "enough", "then", "it", "will", "grow", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/CircularQueue.java#L115-L128
100,368
lessthanoptimal/ddogleg
src/org/ddogleg/struct/CircularQueue.java
CircularQueue.growW
public T growW() { T a; if( size >= data.length) { a = data[start]; if( a == null ) data[start] = a = createInstance(); start = (start+1)%data.length; } else { a = data[(start+size)%data.length]; if( a == null ) data[(start+size)%data.length] = a = createInstance(); size++; } return ...
java
public T growW() { T a; if( size >= data.length) { a = data[start]; if( a == null ) data[start] = a = createInstance(); start = (start+1)%data.length; } else { a = data[(start+size)%data.length]; if( a == null ) data[(start+size)%data.length] = a = createInstance(); size++; } return ...
[ "public", "T", "growW", "(", ")", "{", "T", "a", ";", "if", "(", "size", ">=", "data", ".", "length", ")", "{", "a", "=", "data", "[", "start", "]", ";", "if", "(", "a", "==", "null", ")", "data", "[", "start", "]", "=", "a", "=", "createIn...
Adds a new element to the end of the list and returns it. If the inner array isn't large enough then the oldest element will be written over. @return instance at the tail
[ "Adds", "a", "new", "element", "to", "the", "end", "of", "the", "list", "and", "returns", "it", ".", "If", "the", "inner", "array", "isn", "t", "large", "enough", "then", "the", "oldest", "element", "will", "be", "written", "over", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/CircularQueue.java#L135-L149
100,369
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/trustregion/UnconMinTrustRegionBFGS_F64.java
UnconMinTrustRegionBFGS_F64.initialize
@Override public void initialize(double[] initial, int numberOfParameters, double minimumFunctionValue) { super.initialize(initial, numberOfParameters,minimumFunctionValue); y.reshape(numberOfParameters,1); xPrevious.reshape(numberOfParameters,1); x.reshape(numberOfParameters,1); // set the previous gradie...
java
@Override public void initialize(double[] initial, int numberOfParameters, double minimumFunctionValue) { super.initialize(initial, numberOfParameters,minimumFunctionValue); y.reshape(numberOfParameters,1); xPrevious.reshape(numberOfParameters,1); x.reshape(numberOfParameters,1); // set the previous gradie...
[ "@", "Override", "public", "void", "initialize", "(", "double", "[", "]", "initial", ",", "int", "numberOfParameters", ",", "double", "minimumFunctionValue", ")", "{", "super", ".", "initialize", "(", "initial", ",", "numberOfParameters", ",", "minimumFunctionValu...
Override parent to initialize matrices
[ "Override", "parent", "to", "initialize", "matrices" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/UnconMinTrustRegionBFGS_F64.java#L84-L97
100,370
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/trustregion/UnconMinTrustRegionBFGS_F64.java
UnconMinTrustRegionBFGS_F64.wolfeCondition
protected boolean wolfeCondition( DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj g_k) { double left = CommonOps_DDRM.dot(y,s); double g_s = CommonOps_DDRM.dot(g_k,s); double right = (c2-1)*g_s; if( left >= right ) { return (fx-f_prev) <= c1*g_s; } return false; }
java
protected boolean wolfeCondition( DMatrixRMaj s , DMatrixRMaj y , DMatrixRMaj g_k) { double left = CommonOps_DDRM.dot(y,s); double g_s = CommonOps_DDRM.dot(g_k,s); double right = (c2-1)*g_s; if( left >= right ) { return (fx-f_prev) <= c1*g_s; } return false; }
[ "protected", "boolean", "wolfeCondition", "(", "DMatrixRMaj", "s", ",", "DMatrixRMaj", "y", ",", "DMatrixRMaj", "g_k", ")", "{", "double", "left", "=", "CommonOps_DDRM", ".", "dot", "(", "y", ",", "s", ")", ";", "double", "g_s", "=", "CommonOps_DDRM", ".",...
Indicates if there's sufficient decrease and curvature. If the Wolfe condition is meet then the Hessian will be positive definite. @param s change in state (new - old) @param y change in gradient (new - old) @param g_k Gradient at step k. @return
[ "Indicates", "if", "there", "s", "sufficient", "decrease", "and", "curvature", ".", "If", "the", "Wolfe", "condition", "is", "meet", "then", "the", "Hessian", "will", "be", "positive", "definite", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/UnconMinTrustRegionBFGS_F64.java#L139-L147
100,371
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.reset
public void reset() { Element e = first; while( e != null ) { Element n = e.next; e.clear(); available.add( e ); e = n; } first = last = null; size = 0; }
java
public void reset() { Element e = first; while( e != null ) { Element n = e.next; e.clear(); available.add( e ); e = n; } first = last = null; size = 0; }
[ "public", "void", "reset", "(", ")", "{", "Element", "e", "=", "first", ";", "while", "(", "e", "!=", "null", ")", "{", "Element", "n", "=", "e", ".", "next", ";", "e", ".", "clear", "(", ")", ";", "available", ".", "add", "(", "e", ")", ";",...
Puts the linked list back into its initial state. Elements are saved for later use.
[ "Puts", "the", "linked", "list", "back", "into", "its", "initial", "state", ".", "Elements", "are", "saved", "for", "later", "use", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L44-L54
100,372
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.getElement
public Element<T> getElement( int index , boolean fromFront ) { if( index > size || index < 0 ) { throw new IllegalArgumentException("index is out of bounds"); } if( fromFront ) { Element<T> e = first; for( int i = 0; i < index; i++ ) { e = e.next; } return e; } else { Element<T> e = last;...
java
public Element<T> getElement( int index , boolean fromFront ) { if( index > size || index < 0 ) { throw new IllegalArgumentException("index is out of bounds"); } if( fromFront ) { Element<T> e = first; for( int i = 0; i < index; i++ ) { e = e.next; } return e; } else { Element<T> e = last;...
[ "public", "Element", "<", "T", ">", "getElement", "(", "int", "index", ",", "boolean", "fromFront", ")", "{", "if", "(", "index", ">", "size", "||", "index", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"index is out of bounds\"", ...
Returns the N'th element when counting from the from or from the back @param index Number of elements away from the first or last element. Must be positive. @return if true then the number of elements will be from first otherwise last
[ "Returns", "the", "N", "th", "element", "when", "counting", "from", "the", "from", "or", "from", "the", "back" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L71-L88
100,373
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.pushHead
public Element<T> pushHead( T object ) { Element<T> e = requestNew(); e.object = object; if( first == null ) { first = last = e; } else { e.next = first; first.previous = e; first = e; } size++; return e; }
java
public Element<T> pushHead( T object ) { Element<T> e = requestNew(); e.object = object; if( first == null ) { first = last = e; } else { e.next = first; first.previous = e; first = e; } size++; return e; }
[ "public", "Element", "<", "T", ">", "pushHead", "(", "T", "object", ")", "{", "Element", "<", "T", ">", "e", "=", "requestNew", "(", ")", ";", "e", ".", "object", "=", "object", ";", "if", "(", "first", "==", "null", ")", "{", "first", "=", "la...
Adds the element to the front of the list. @param object Object being added. @return The element it was placed inside of
[ "Adds", "the", "element", "to", "the", "front", "of", "the", "list", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L96-L110
100,374
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.pushTail
public Element<T> pushTail( T object ) { Element<T> e = requestNew(); e.object = object; if( last == null ) { first = last = e; } else { e.previous = last; last.next = e; last = e; } size++; return e; }
java
public Element<T> pushTail( T object ) { Element<T> e = requestNew(); e.object = object; if( last == null ) { first = last = e; } else { e.previous = last; last.next = e; last = e; } size++; return e; }
[ "public", "Element", "<", "T", ">", "pushTail", "(", "T", "object", ")", "{", "Element", "<", "T", ">", "e", "=", "requestNew", "(", ")", ";", "e", ".", "object", "=", "object", ";", "if", "(", "last", "==", "null", ")", "{", "first", "=", "las...
Adds the element to the back of the list. @param object Object being added. @return The element it was placed inside of
[ "Adds", "the", "element", "to", "the", "back", "of", "the", "list", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L118-L132
100,375
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.insertAfter
public Element<T> insertAfter( Element<T> previous , T object ) { Element<T> e = requestNew(); e.object = object; e.previous = previous; e.next = previous.next; if( e.next != null ) { e.next.previous = e; } else { last = e; } previous.next = e; size++; return e; }
java
public Element<T> insertAfter( Element<T> previous , T object ) { Element<T> e = requestNew(); e.object = object; e.previous = previous; e.next = previous.next; if( e.next != null ) { e.next.previous = e; } else { last = e; } previous.next = e; size++; return e; }
[ "public", "Element", "<", "T", ">", "insertAfter", "(", "Element", "<", "T", ">", "previous", ",", "T", "object", ")", "{", "Element", "<", "T", ">", "e", "=", "requestNew", "(", ")", ";", "e", ".", "object", "=", "object", ";", "e", ".", "previo...
Inserts the object into a new element after the provided element. @param previous Element which will be before the new one @param object The object which goes into the new element @return The new element
[ "Inserts", "the", "object", "into", "a", "new", "element", "after", "the", "provided", "element", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L141-L154
100,376
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.insertBefore
public Element<T> insertBefore( Element<T> next , T object ) { Element<T> e = requestNew(); e.object = object; e.previous = next.previous; e.next = next; if( e.previous != null ) { e.previous.next = e; } else { first = e; } next.previous = e; size++; return e; }
java
public Element<T> insertBefore( Element<T> next , T object ) { Element<T> e = requestNew(); e.object = object; e.previous = next.previous; e.next = next; if( e.previous != null ) { e.previous.next = e; } else { first = e; } next.previous = e; size++; return e; }
[ "public", "Element", "<", "T", ">", "insertBefore", "(", "Element", "<", "T", ">", "next", ",", "T", "object", ")", "{", "Element", "<", "T", ">", "e", "=", "requestNew", "(", ")", ";", "e", ".", "object", "=", "object", ";", "e", ".", "previous"...
Inserts the object into a new element before the provided element. @param next Element which will be after the new one @param object The object which goes into the new element @return The new element
[ "Inserts", "the", "object", "into", "a", "new", "element", "before", "the", "provided", "element", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L163-L177
100,377
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.swap
public void swap( Element<T> a , Element<T> b ) { if (a.next == b) { if( a.previous != null ) { a.previous.next = b; } if( b.next != null ) { b.next.previous = a; } Element<T> tmp = a.previous; a.previous = b; a.next = b.next; b.previous = tmp; b.next = a; if( first == a ) fi...
java
public void swap( Element<T> a , Element<T> b ) { if (a.next == b) { if( a.previous != null ) { a.previous.next = b; } if( b.next != null ) { b.next.previous = a; } Element<T> tmp = a.previous; a.previous = b; a.next = b.next; b.previous = tmp; b.next = a; if( first == a ) fi...
[ "public", "void", "swap", "(", "Element", "<", "T", ">", "a", ",", "Element", "<", "T", ">", "b", ")", "{", "if", "(", "a", ".", "next", "==", "b", ")", "{", "if", "(", "a", ".", "previous", "!=", "null", ")", "{", "a", ".", "previous", "."...
Swaps the location of the two elements @param a Element @param b Element
[ "Swaps", "the", "location", "of", "the", "two", "elements" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L185-L248
100,378
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.remove
public void remove( Element<T> element ) { if( element.next == null ) { last = element.previous; } else { element.next.previous = element.previous; } if( element.previous == null ) { first = element.next; } else { element.previous.next = element.next; } size--; element.clear(); available.p...
java
public void remove( Element<T> element ) { if( element.next == null ) { last = element.previous; } else { element.next.previous = element.previous; } if( element.previous == null ) { first = element.next; } else { element.previous.next = element.next; } size--; element.clear(); available.p...
[ "public", "void", "remove", "(", "Element", "<", "T", ">", "element", ")", "{", "if", "(", "element", ".", "next", "==", "null", ")", "{", "last", "=", "element", ".", "previous", ";", "}", "else", "{", "element", ".", "next", ".", "previous", "=",...
Removes the element from the list and saves the element data structure for later reuse. @param element The item which is to be removed from the list
[ "Removes", "the", "element", "from", "the", "list", "and", "saves", "the", "element", "data", "structure", "for", "later", "reuse", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L254-L268
100,379
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.removeHead
public T removeHead() { if( first == null ) throw new IllegalArgumentException("Empty list"); T ret = first.getObject(); Element<T> e = first; available.push(first); if( first.next != null ) { first.next.previous = null; first = first.next; } else { // there's only one element in the list f...
java
public T removeHead() { if( first == null ) throw new IllegalArgumentException("Empty list"); T ret = first.getObject(); Element<T> e = first; available.push(first); if( first.next != null ) { first.next.previous = null; first = first.next; } else { // there's only one element in the list f...
[ "public", "T", "removeHead", "(", ")", "{", "if", "(", "first", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Empty list\"", ")", ";", "T", "ret", "=", "first", ".", "getObject", "(", ")", ";", "Element", "<", "T", ">", "e", ...
Removes the first element from the list @return The object which was contained in the first element
[ "Removes", "the", "first", "element", "from", "the", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L274-L292
100,380
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.removeTail
public Object removeTail() { if( last == null ) throw new IllegalArgumentException("Empty list"); Object ret = last.getObject(); Element<T> e = last; available.add(last); if( last.previous != null ) { last.previous.next = null; last = last.previous; } else { // there's only one element in the ...
java
public Object removeTail() { if( last == null ) throw new IllegalArgumentException("Empty list"); Object ret = last.getObject(); Element<T> e = last; available.add(last); if( last.previous != null ) { last.previous.next = null; last = last.previous; } else { // there's only one element in the ...
[ "public", "Object", "removeTail", "(", ")", "{", "if", "(", "last", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Empty list\"", ")", ";", "Object", "ret", "=", "last", ".", "getObject", "(", ")", ";", "Element", "<", "T", ">", ...
Removes the last element from the list @return The object which was contained in the lsat element
[ "Removes", "the", "last", "element", "from", "the", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L298-L316
100,381
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.find
public Element<T> find( T object ) { Element<T> e = first; while( e != null ) { if( e.object == object ) { return e; } e = e.next; } return null; }
java
public Element<T> find( T object ) { Element<T> e = first; while( e != null ) { if( e.object == object ) { return e; } e = e.next; } return null; }
[ "public", "Element", "<", "T", ">", "find", "(", "T", "object", ")", "{", "Element", "<", "T", ">", "e", "=", "first", ";", "while", "(", "e", "!=", "null", ")", "{", "if", "(", "e", ".", "object", "==", "object", ")", "{", "return", "e", ";"...
Returns the first element which contains 'object' starting from the head. @param object Object which is being searched for @return First element which contains object or null if none can be found
[ "Returns", "the", "first", "element", "which", "contains", "object", "starting", "from", "the", "head", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L323-L332
100,382
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.addAll
public void addAll( List<T> list ) { if( list.isEmpty() ) return; Element<T> a = requestNew(); a.object = list.get(0); if( first == null ) { first = a; } else if( last != null ) { last.next = a; a.previous = last; } for (int i = 1; i < list.size(); i++) { Element<T> b = requestNew(); ...
java
public void addAll( List<T> list ) { if( list.isEmpty() ) return; Element<T> a = requestNew(); a.object = list.get(0); if( first == null ) { first = a; } else if( last != null ) { last.next = a; a.previous = last; } for (int i = 1; i < list.size(); i++) { Element<T> b = requestNew(); ...
[ "public", "void", "addAll", "(", "List", "<", "T", ">", "list", ")", "{", "if", "(", "list", ".", "isEmpty", "(", ")", ")", "return", ";", "Element", "<", "T", ">", "a", "=", "requestNew", "(", ")", ";", "a", ".", "object", "=", "list", ".", ...
Add all elements in list into this linked list @param list List
[ "Add", "all", "elements", "in", "list", "into", "this", "linked", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L354-L379
100,383
lessthanoptimal/ddogleg
src/org/ddogleg/struct/LinkedList.java
LinkedList.addAll
public void addAll( T[] array , int first , int length ) { if( length <= 0 ) return; Element<T> a = requestNew(); a.object = array[first]; if( this.first == null ) { this.first = a; } else if( last != null ) { last.next = a; a.previous = last; } for (int i = 1; i < length; i++) { Element...
java
public void addAll( T[] array , int first , int length ) { if( length <= 0 ) return; Element<T> a = requestNew(); a.object = array[first]; if( this.first == null ) { this.first = a; } else if( last != null ) { last.next = a; a.previous = last; } for (int i = 1; i < length; i++) { Element...
[ "public", "void", "addAll", "(", "T", "[", "]", "array", ",", "int", "first", ",", "int", "length", ")", "{", "if", "(", "length", "<=", "0", ")", "return", ";", "Element", "<", "T", ">", "a", "=", "requestNew", "(", ")", ";", "a", ".", "object...
Adds the specified elements from array into this list @param array The array @param first First element to be added @param length The number of elements to be added
[ "Adds", "the", "specified", "elements", "from", "array", "into", "this", "list" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/LinkedList.java#L387-L412
100,384
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/gmm/GaussianGmm_F64.java
GaussianGmm_F64.addMean
public void addMean( double[] point , double responsibility ) { for (int i = 0; i < mean.numRows; i++) { mean.data[i] += responsibility*point[i]; } weight += responsibility; }
java
public void addMean( double[] point , double responsibility ) { for (int i = 0; i < mean.numRows; i++) { mean.data[i] += responsibility*point[i]; } weight += responsibility; }
[ "public", "void", "addMean", "(", "double", "[", "]", "point", ",", "double", "responsibility", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mean", ".", "numRows", ";", "i", "++", ")", "{", "mean", ".", "data", "[", "i", "]", "+=...
Helper function for computing Gaussian parameters. Adds the point to mean and weight.
[ "Helper", "function", "for", "computing", "Gaussian", "parameters", ".", "Adds", "the", "point", "to", "mean", "and", "weight", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/GaussianGmm_F64.java#L62-L67
100,385
lessthanoptimal/ddogleg
src/org/ddogleg/clustering/gmm/GaussianGmm_F64.java
GaussianGmm_F64.addCovariance
public void addCovariance( double[] difference , double responsibility ) { int N = mean.numRows; for (int i = 0; i < N; i++) { for (int j = i; j < N; j++) { covariance.data[i*N+j] += responsibility*difference[i]*difference[j]; } } for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { cov...
java
public void addCovariance( double[] difference , double responsibility ) { int N = mean.numRows; for (int i = 0; i < N; i++) { for (int j = i; j < N; j++) { covariance.data[i*N+j] += responsibility*difference[i]*difference[j]; } } for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { cov...
[ "public", "void", "addCovariance", "(", "double", "[", "]", "difference", ",", "double", "responsibility", ")", "{", "int", "N", "=", "mean", ".", "numRows", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "fo...
Helper function for computing Gaussian parameters. Adds the difference between point and mean to covariance, adjusted by the weight.
[ "Helper", "function", "for", "computing", "Gaussian", "parameters", ".", "Adds", "the", "difference", "between", "point", "and", "mean", "to", "covariance", "adjusted", "by", "the", "weight", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/GaussianGmm_F64.java#L73-L86
100,386
lessthanoptimal/ddogleg
src/org/ddogleg/struct/GrowQueue_B.java
GrowQueue_B.zeros
public static GrowQueue_B zeros( int length ) { GrowQueue_B out = new GrowQueue_B(length); out.size = length; return out; }
java
public static GrowQueue_B zeros( int length ) { GrowQueue_B out = new GrowQueue_B(length); out.size = length; return out; }
[ "public", "static", "GrowQueue_B", "zeros", "(", "int", "length", ")", "{", "GrowQueue_B", "out", "=", "new", "GrowQueue_B", "(", "length", ")", ";", "out", ".", "size", "=", "length", ";", "return", "out", ";", "}" ]
Creates a queue with the specified length as its size filled with false
[ "Creates", "a", "queue", "with", "the", "specified", "length", "as", "its", "size", "filled", "with", "false" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_B.java#L46-L50
100,387
lessthanoptimal/ddogleg
src/org/ddogleg/stats/UtilStatisticsInt.java
UtilStatisticsInt.findMaxIndex
public static int findMaxIndex( int[] a ) { int max = a[0]; int index = 0; for( int i = 1; i< a.length; i++ ) { int val = a[i]; if( val > max ) { max = val; index = i; } } return index; }
java
public static int findMaxIndex( int[] a ) { int max = a[0]; int index = 0; for( int i = 1; i< a.length; i++ ) { int val = a[i]; if( val > max ) { max = val; index = i; } } return index; }
[ "public", "static", "int", "findMaxIndex", "(", "int", "[", "]", "a", ")", "{", "int", "max", "=", "a", "[", "0", "]", ";", "int", "index", "=", "0", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "a", ".", "length", ";", "i", "++", ...
Finds the index in 'a' with the largest value. @param a Input array @return Index of largest value
[ "Finds", "the", "index", "in", "a", "with", "the", "largest", "value", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/stats/UtilStatisticsInt.java#L31-L45
100,388
lessthanoptimal/ddogleg
src/org/ddogleg/graph/GraphDataManager.java
GraphDataManager.reset
public void reset() { unusedEdges.addAll(usedEdges); unusedNodes.addAll(usedNodes); usedEdges.clear(); usedNodes.clear(); }
java
public void reset() { unusedEdges.addAll(usedEdges); unusedNodes.addAll(usedNodes); usedEdges.clear(); usedNodes.clear(); }
[ "public", "void", "reset", "(", ")", "{", "unusedEdges", ".", "addAll", "(", "usedEdges", ")", ";", "unusedNodes", ".", "addAll", "(", "usedNodes", ")", ";", "usedEdges", ".", "clear", "(", ")", ";", "usedNodes", ".", "clear", "(", ")", ";", "}" ]
Takes all the used nodes and makes them unused.
[ "Takes", "all", "the", "used", "nodes", "and", "makes", "them", "unused", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/graph/GraphDataManager.java#L45-L52
100,389
lessthanoptimal/ddogleg
src/org/ddogleg/graph/GraphDataManager.java
GraphDataManager.resetHard
public void resetHard() { for( int i = 0; i < usedEdges.size(); i++ ) { Edge<N,E> e = usedEdges.get(i); e.data = null; e.dest = null; } for( int i = 0; i < usedNodes.size(); i++ ) { Node<N,E> n = usedNodes.get(i); n.data = null; n.edges.reset(); ...
java
public void resetHard() { for( int i = 0; i < usedEdges.size(); i++ ) { Edge<N,E> e = usedEdges.get(i); e.data = null; e.dest = null; } for( int i = 0; i < usedNodes.size(); i++ ) { Node<N,E> n = usedNodes.get(i); n.data = null; n.edges.reset(); ...
[ "public", "void", "resetHard", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "usedEdges", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Edge", "<", "N", ",", "E", ">", "e", "=", "usedEdges", ".", "get", "(", "i", ")", ...
Takes all the used nodes and makes them unused. Also dereferences any objects saved in 'data'.
[ "Takes", "all", "the", "used", "nodes", "and", "makes", "them", "unused", ".", "Also", "dereferences", "any", "objects", "saved", "in", "data", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/graph/GraphDataManager.java#L57-L75
100,390
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.init
protected void init(int initialMaxSize, Class<T> type, Factory<T> factory) { this.size = 0; this.type = type; this.factory = factory; data = (T[]) Array.newInstance(type, initialMaxSize); if( factory != null ) { for( int i = 0; i < initialMaxSize; i++ ) { try { data[i] = createInstance(); } ...
java
protected void init(int initialMaxSize, Class<T> type, Factory<T> factory) { this.size = 0; this.type = type; this.factory = factory; data = (T[]) Array.newInstance(type, initialMaxSize); if( factory != null ) { for( int i = 0; i < initialMaxSize; i++ ) { try { data[i] = createInstance(); } ...
[ "protected", "void", "init", "(", "int", "initialMaxSize", ",", "Class", "<", "T", ">", "type", ",", "Factory", "<", "T", ">", "factory", ")", "{", "this", ".", "size", "=", "0", ";", "this", ".", "type", "=", "type", ";", "this", ".", "factory", ...
Data structure initialization is done here so that child classes can declay initialization until they are ready
[ "Data", "structure", "initialization", "is", "done", "here", "so", "that", "child", "classes", "can", "declay", "initialization", "until", "they", "are", "ready" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L72-L88
100,391
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.reverse
public void reverse() { for (int i = 0; i < size / 2; i++) { T tmp = data[i]; data[i] = data[size - i - 1]; data[size - i - 1] = tmp; } }
java
public void reverse() { for (int i = 0; i < size / 2; i++) { T tmp = data[i]; data[i] = data[size - i - 1]; data[size - i - 1] = tmp; } }
[ "public", "void", "reverse", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", "/", "2", ";", "i", "++", ")", "{", "T", "tmp", "=", "data", "[", "i", "]", ";", "data", "[", "i", "]", "=", "data", "[", "size", "-", ...
Reverse the item order in this queue.
[ "Reverse", "the", "item", "order", "in", "this", "queue", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L144-L150
100,392
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.get
public T get( int index ) { if( index >= size ) throw new IllegalArgumentException("Index out of bounds: index "+index+" size "+size); return data[index]; }
java
public T get( int index ) { if( index >= size ) throw new IllegalArgumentException("Index out of bounds: index "+index+" size "+size); return data[index]; }
[ "public", "T", "get", "(", "int", "index", ")", "{", "if", "(", "index", ">=", "size", ")", "throw", "new", "IllegalArgumentException", "(", "\"Index out of bounds: index \"", "+", "index", "+", "\" size \"", "+", "size", ")", ";", "return", "data", "[", "...
Returns the element at the specified index. Bounds checking is performed. @param index Index of the element being retrieved @return The retrieved element
[ "Returns", "the", "element", "at", "the", "specified", "index", ".", "Bounds", "checking", "is", "performed", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L157-L161
100,393
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.grow
public T grow() { if( size < data.length ) { return data[size++]; } else { growArray((data.length+1)*2); return data[size++]; } }
java
public T grow() { if( size < data.length ) { return data[size++]; } else { growArray((data.length+1)*2); return data[size++]; } }
[ "public", "T", "grow", "(", ")", "{", "if", "(", "size", "<", "data", ".", "length", ")", "{", "return", "data", "[", "size", "++", "]", ";", "}", "else", "{", "growArray", "(", "(", "data", ".", "length", "+", "1", ")", "*", "2", ")", ";", ...
Returns a new element of data. If there are new data elements available then array will automatically grow. @return A new instance.
[ "Returns", "a", "new", "element", "of", "data", ".", "If", "there", "are", "new", "data", "elements", "available", "then", "array", "will", "automatically", "grow", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L169-L176
100,394
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.remove
public void remove( int index ) { T removed = data[index]; for( int i = index+1; i < size; i++ ) { data[i-1] = data[i]; } data[size-1] = removed; size--; }
java
public void remove( int index ) { T removed = data[index]; for( int i = index+1; i < size; i++ ) { data[i-1] = data[i]; } data[size-1] = removed; size--; }
[ "public", "void", "remove", "(", "int", "index", ")", "{", "T", "removed", "=", "data", "[", "index", "]", ";", "for", "(", "int", "i", "=", "index", "+", "1", ";", "i", "<", "size", ";", "i", "++", ")", "{", "data", "[", "i", "-", "1", "]"...
Removes an element from the queue by shifting elements in the array down one and placing the removed element at the old end of the list. @param index Index of the element being removed
[ "Removes", "an", "element", "from", "the", "queue", "by", "shifting", "elements", "in", "the", "array", "down", "one", "and", "placing", "the", "removed", "element", "at", "the", "old", "end", "of", "the", "list", "." ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L184-L191
100,395
lessthanoptimal/ddogleg
src/org/ddogleg/struct/FastQueue.java
FastQueue.growArray
public void growArray( int length) { // now need to grow since it is already larger if( this.data.length >= length) return; T []data = (T[])Array.newInstance(type, length); System.arraycopy(this.data,0,data,0,this.data.length); if( factory != null ) { for( int i = this.data.length; i < length; i++ ) {...
java
public void growArray( int length) { // now need to grow since it is already larger if( this.data.length >= length) return; T []data = (T[])Array.newInstance(type, length); System.arraycopy(this.data,0,data,0,this.data.length); if( factory != null ) { for( int i = this.data.length; i < length; i++ ) {...
[ "public", "void", "growArray", "(", "int", "length", ")", "{", "// now need to grow since it is already larger", "if", "(", "this", ".", "data", ".", "length", ">=", "length", ")", "return", ";", "T", "[", "]", "data", "=", "(", "T", "[", "]", ")", "Arra...
Increases the size of the internal array without changing the shape's size. If the array is already larger than the specified length then nothing is done. Elements previously stored in the array are copied over is a new internal array is declared. @param length Requested size of internal array.
[ "Increases", "the", "size", "of", "the", "internal", "array", "without", "changing", "the", "shape", "s", "size", ".", "If", "the", "array", "is", "already", "larger", "than", "the", "specified", "length", "then", "nothing", "is", "done", ".", "Elements", ...
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/FastQueue.java#L219-L233
100,396
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/trustregion/TrustRegionUpdateDogleg_F64.java
TrustRegionUpdateDogleg_F64.cauchyStep
protected void cauchyStep(double regionRadius, DMatrixRMaj step) { CommonOps_DDRM.scale(-regionRadius, direction, step); stepLength = regionRadius; // it touches the trust region predictedReduction = regionRadius*(owner.gradientNorm - 0.5*regionRadius*gBg); }
java
protected void cauchyStep(double regionRadius, DMatrixRMaj step) { CommonOps_DDRM.scale(-regionRadius, direction, step); stepLength = regionRadius; // it touches the trust region predictedReduction = regionRadius*(owner.gradientNorm - 0.5*regionRadius*gBg); }
[ "protected", "void", "cauchyStep", "(", "double", "regionRadius", ",", "DMatrixRMaj", "step", ")", "{", "CommonOps_DDRM", ".", "scale", "(", "-", "regionRadius", ",", "direction", ",", "step", ")", ";", "stepLength", "=", "regionRadius", ";", "// it touches the ...
Computes the Cauchy step, This is only called if the Cauchy point lies after or on the trust region @param regionRadius (Input) Trust region size @param step (Output) The step
[ "Computes", "the", "Cauchy", "step", "This", "is", "only", "called", "if", "the", "Cauchy", "point", "lies", "after", "or", "on", "the", "trust", "region" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionUpdateDogleg_F64.java#L184-L189
100,397
lessthanoptimal/ddogleg
src/org/ddogleg/optimization/trustregion/TrustRegionUpdateDogleg_F64.java
TrustRegionUpdateDogleg_F64.fractionCauchyToGN
static double fractionCauchyToGN(double lengthCauchy , double lengthGN , double lengthPtoGN, double region ) { // First triangle has 3 known sides double a=lengthGN,b=lengthCauchy,c=lengthPtoGN; // Law of cosine to find angle for side GN (a.k.a 'a') double cosineA = (a*a - b*b - c*c)/(-2.0*b*c); double angl...
java
static double fractionCauchyToGN(double lengthCauchy , double lengthGN , double lengthPtoGN, double region ) { // First triangle has 3 known sides double a=lengthGN,b=lengthCauchy,c=lengthPtoGN; // Law of cosine to find angle for side GN (a.k.a 'a') double cosineA = (a*a - b*b - c*c)/(-2.0*b*c); double angl...
[ "static", "double", "fractionCauchyToGN", "(", "double", "lengthCauchy", ",", "double", "lengthGN", ",", "double", "lengthPtoGN", ",", "double", "region", ")", "{", "// First triangle has 3 known sides", "double", "a", "=", "lengthGN", ",", "b", "=", "lengthCauchy",...
Compute the fractional distance from P to GN where the point intersects the region's boundary
[ "Compute", "the", "fractional", "distance", "from", "P", "to", "GN", "where", "the", "point", "intersects", "the", "region", "s", "boundary" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionUpdateDogleg_F64.java#L207-L225
100,398
lessthanoptimal/ddogleg
src/org/ddogleg/rand/MultivariateGaussianDraw.java
MultivariateGaussianDraw.next
public DMatrixRMaj next( DMatrixRMaj x ) { for( int i = 0; i < r.numRows; i++ ) { r.set(i,0,rand.nextGaussian()); } x.set(mean); multAdd(A,r,x); return x; }
java
public DMatrixRMaj next( DMatrixRMaj x ) { for( int i = 0; i < r.numRows; i++ ) { r.set(i,0,rand.nextGaussian()); } x.set(mean); multAdd(A,r,x); return x; }
[ "public", "DMatrixRMaj", "next", "(", "DMatrixRMaj", "x", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "r", ".", "numRows", ";", "i", "++", ")", "{", "r", ".", "set", "(", "i", ",", "0", ",", "rand", ".", "nextGaussian", "(", ")...
Makes a draw on the distribution and stores the results in parameter 'x'
[ "Makes", "a", "draw", "on", "the", "distribution", "and", "stores", "the", "results", "in", "parameter", "x" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/rand/MultivariateGaussianDraw.java#L90-L100
100,399
lessthanoptimal/ddogleg
src/org/ddogleg/fitting/modelset/ransac/Ransac.java
Ransac.initialize
public void initialize( List<Point> dataSet ) { bestFitPoints.clear(); if( dataSet.size() > matchToInput.length ) { matchToInput = new int[ dataSet.size() ]; bestMatchToInput = new int[ dataSet.size() ]; } }
java
public void initialize( List<Point> dataSet ) { bestFitPoints.clear(); if( dataSet.size() > matchToInput.length ) { matchToInput = new int[ dataSet.size() ]; bestMatchToInput = new int[ dataSet.size() ]; } }
[ "public", "void", "initialize", "(", "List", "<", "Point", ">", "dataSet", ")", "{", "bestFitPoints", ".", "clear", "(", ")", ";", "if", "(", "dataSet", ".", "size", "(", ")", ">", "matchToInput", ".", "length", ")", "{", "matchToInput", "=", "new", ...
Initialize internal data structures
[ "Initialize", "internal", "data", "structures" ]
3786bf448ba23d0e04962dd08c34fa68de276029
https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/ransac/Ransac.java#L155-L162