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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/fitting/modelset/ransac/Ransac.java | Ransac.randomDraw | public static <T> void randomDraw(List<T> dataSet, int numSample,
List<T> initialSample, Random rand) {
initialSample.clear();
for (int i = 0; i < numSample; i++) {
// index of last element that has not been selected
int indexLast = dataSet.size()-i-1;
// randomly select an item from the list w... | java | public static <T> void randomDraw(List<T> dataSet, int numSample,
List<T> initialSample, Random rand) {
initialSample.clear();
for (int i = 0; i < numSample; i++) {
// index of last element that has not been selected
int indexLast = dataSet.size()-i-1;
// randomly select an item from the list w... | [
"public",
"static",
"<",
"T",
">",
"void",
"randomDraw",
"(",
"List",
"<",
"T",
">",
"dataSet",
",",
"int",
"numSample",
",",
"List",
"<",
"T",
">",
"initialSample",
",",
"Random",
"rand",
")",
"{",
"initialSample",
".",
"clear",
"(",
")",
";",
"for"... | Performs a random draw in the dataSet. When an element is selected it is moved to the end of the list
so that it can't be selected again.
@param dataSet List that points are to be selected from. Modified. | [
"Performs",
"a",
"random",
"draw",
"in",
"the",
"dataSet",
".",
"When",
"an",
"element",
"is",
"selected",
"it",
"is",
"moved",
"to",
"the",
"end",
"of",
"the",
"list",
"so",
"that",
"it",
"can",
"t",
"be",
"selected",
"again",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/ransac/Ransac.java#L170-L187 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/fitting/modelset/ransac/Ransac.java | Ransac.selectMatchSet | @SuppressWarnings({"ForLoopReplaceableByForEach"})
protected void selectMatchSet(List<Point> dataSet, double threshold, Model param) {
candidatePoints.clear();
modelDistance.setModel(param);
for (int i = 0; i < dataSet.size(); i++) {
Point point = dataSet.get(i);
double distance = modelDistance.computeDi... | java | @SuppressWarnings({"ForLoopReplaceableByForEach"})
protected void selectMatchSet(List<Point> dataSet, double threshold, Model param) {
candidatePoints.clear();
modelDistance.setModel(param);
for (int i = 0; i < dataSet.size(); i++) {
Point point = dataSet.get(i);
double distance = modelDistance.computeDi... | [
"@",
"SuppressWarnings",
"(",
"{",
"\"ForLoopReplaceableByForEach\"",
"}",
")",
"protected",
"void",
"selectMatchSet",
"(",
"List",
"<",
"Point",
">",
"dataSet",
",",
"double",
"threshold",
",",
"Model",
"param",
")",
"{",
"candidatePoints",
".",
"clear",
"(",
... | Looks for points in the data set which closely match the current best
fit model in the optimizer.
@param dataSet The points being considered | [
"Looks",
"for",
"points",
"in",
"the",
"data",
"set",
"which",
"closely",
"match",
"the",
"current",
"best",
"fit",
"model",
"in",
"the",
"optimizer",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/ransac/Ransac.java#L195-L209 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java | StandardKMeans_F64.matchPointsToClusters | protected void matchPointsToClusters(List<double[]> points) {
sumDistance = 0;
for (int i = 0; i < points.size(); i++) {
double[]p = points.get(i);
// find the cluster which is closest to the point
int bestCluster = findBestMatch(p);
// sum up all the points which are members of this cluster
double... | java | protected void matchPointsToClusters(List<double[]> points) {
sumDistance = 0;
for (int i = 0; i < points.size(); i++) {
double[]p = points.get(i);
// find the cluster which is closest to the point
int bestCluster = findBestMatch(p);
// sum up all the points which are members of this cluster
double... | [
"protected",
"void",
"matchPointsToClusters",
"(",
"List",
"<",
"double",
"[",
"]",
">",
"points",
")",
"{",
"sumDistance",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",... | Finds the cluster which is the closest to each point. The point is the added to the sum for the cluster
and its member count incremented | [
"Finds",
"the",
"cluster",
"which",
"is",
"the",
"closest",
"to",
"each",
"point",
".",
"The",
"point",
"is",
"the",
"added",
"to",
"the",
"sum",
"for",
"the",
"cluster",
"and",
"its",
"member",
"count",
"incremented"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java#L200-L217 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java | StandardKMeans_F64.findBestMatch | protected int findBestMatch(double[] p) {
int bestCluster = -1;
bestDistance = Double.MAX_VALUE;
for (int j = 0; j < clusters.size; j++) {
double d = distanceSq(p,clusters.get(j));
if( d < bestDistance ) {
bestDistance = d;
bestCluster = j;
}
}
return bestCluster;
} | java | protected int findBestMatch(double[] p) {
int bestCluster = -1;
bestDistance = Double.MAX_VALUE;
for (int j = 0; j < clusters.size; j++) {
double d = distanceSq(p,clusters.get(j));
if( d < bestDistance ) {
bestDistance = d;
bestCluster = j;
}
}
return bestCluster;
} | [
"protected",
"int",
"findBestMatch",
"(",
"double",
"[",
"]",
"p",
")",
"{",
"int",
"bestCluster",
"=",
"-",
"1",
";",
"bestDistance",
"=",
"Double",
".",
"MAX_VALUE",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"clusters",
".",
"size",
"... | Searches for this cluster which is the closest to p | [
"Searches",
"for",
"this",
"cluster",
"which",
"is",
"the",
"closest",
"to",
"p"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java#L222-L234 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java | StandardKMeans_F64.updateClusterCenters | protected void updateClusterCenters() {
// compute the new centers of each cluster
for (int i = 0; i < clusters.size; i++) {
double mc = memberCount.get(i);
double[] w = workClusters.get(i);
double[] c = clusters.get(i);
for (int j = 0; j < w.length; j++) {
c[j] = w[j] / mc;
}
}
} | java | protected void updateClusterCenters() {
// compute the new centers of each cluster
for (int i = 0; i < clusters.size; i++) {
double mc = memberCount.get(i);
double[] w = workClusters.get(i);
double[] c = clusters.get(i);
for (int j = 0; j < w.length; j++) {
c[j] = w[j] / mc;
}
}
} | [
"protected",
"void",
"updateClusterCenters",
"(",
")",
"{",
"// compute the new centers of each cluster",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clusters",
".",
"size",
";",
"i",
"++",
")",
"{",
"double",
"mc",
"=",
"memberCount",
".",
"get",
"(... | Sets the location of each cluster to the average location of all its members. | [
"Sets",
"the",
"location",
"of",
"each",
"cluster",
"to",
"the",
"average",
"location",
"of",
"all",
"its",
"members",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java#L239-L250 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java | StandardKMeans_F64.distanceSq | protected static double distanceSq(double[] a, double[] b) {
double sum = 0;
for (int i = 0; i < a.length; i++) {
double d = a[i]-b[i];
sum += d*d;
}
return sum;
} | java | protected static double distanceSq(double[] a, double[] b) {
double sum = 0;
for (int i = 0; i < a.length; i++) {
double d = a[i]-b[i];
sum += d*d;
}
return sum;
} | [
"protected",
"static",
"double",
"distanceSq",
"(",
"double",
"[",
"]",
"a",
",",
"double",
"[",
"]",
"b",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"length",
";",
"i",
"++",
")",
"{"... | Returns the euclidean distance squared between the two poits | [
"Returns",
"the",
"euclidean",
"distance",
"squared",
"between",
"the",
"two",
"poits"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/kmeans/StandardKMeans_F64.java#L255-L262 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/RecycleManager.java | RecycleManager.requestInstance | public T requestInstance() {
T a;
if( unused.size() > 0 ) {
a = unused.pop();
} else {
a = createInstance();
}
return a;
} | java | public T requestInstance() {
T a;
if( unused.size() > 0 ) {
a = unused.pop();
} else {
a = createInstance();
}
return a;
} | [
"public",
"T",
"requestInstance",
"(",
")",
"{",
"T",
"a",
";",
"if",
"(",
"unused",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"a",
"=",
"unused",
".",
"pop",
"(",
")",
";",
"}",
"else",
"{",
"a",
"=",
"createInstance",
"(",
")",
";",
"}",
... | Either returns a recycled instance or a new one. | [
"Either",
"returns",
"a",
"recycled",
"instance",
"or",
"a",
"new",
"one",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/RecycleManager.java#L43-L51 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/RecycleManager.java | RecycleManager.createInstance | protected T createInstance() {
try {
return targetClass.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | protected T createInstance() {
try {
return targetClass.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"protected",
"T",
"createInstance",
"(",
")",
"{",
"try",
"{",
"return",
"targetClass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"... | Creates a new instance using the class. overload this to handle more complex constructors | [
"Creates",
"a",
"new",
"instance",
"using",
"the",
"class",
".",
"overload",
"this",
"to",
"handle",
"more",
"complex",
"constructors"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/RecycleManager.java#L63-L71 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java | QuasiNewtonBFGS.setFunction | public void setFunction( GradientLineFunction function , double funcMinValue ) {
this.function = function;
this.funcMinValue = funcMinValue;
lineSearch.setFunction(function,funcMinValue);
N = function.getN();
B = new DMatrixRMaj(N,N);
searchVector = new DMatrixRMaj(N,1);
g = new DMatrixRMaj(N,1);
s = ... | java | public void setFunction( GradientLineFunction function , double funcMinValue ) {
this.function = function;
this.funcMinValue = funcMinValue;
lineSearch.setFunction(function,funcMinValue);
N = function.getN();
B = new DMatrixRMaj(N,N);
searchVector = new DMatrixRMaj(N,1);
g = new DMatrixRMaj(N,1);
s = ... | [
"public",
"void",
"setFunction",
"(",
"GradientLineFunction",
"function",
",",
"double",
"funcMinValue",
")",
"{",
"this",
".",
"function",
"=",
"function",
";",
"this",
".",
"funcMinValue",
"=",
"funcMinValue",
";",
"lineSearch",
".",
"setFunction",
"(",
"funct... | Specify the function being optimized
@param function Function to optimize
@param funcMinValue Minimum possible function value. E.g. 0 for least squares. | [
"Specify",
"the",
"function",
"being",
"optimized"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java#L122-L138 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java | QuasiNewtonBFGS.computeSearchDirection | private boolean computeSearchDirection() {
// Compute the function's gradient
function.computeGradient(temp0_Nx1.data);
// compute the change in gradient
for( int i = 0; i < N; i++ ) {
y.data[i] = temp0_Nx1.data[i] - g.data[i];
g.data[i] = temp0_Nx1.data[i];
}
// Update the inverse Hessian matrix
... | java | private boolean computeSearchDirection() {
// Compute the function's gradient
function.computeGradient(temp0_Nx1.data);
// compute the change in gradient
for( int i = 0; i < N; i++ ) {
y.data[i] = temp0_Nx1.data[i] - g.data[i];
g.data[i] = temp0_Nx1.data[i];
}
// Update the inverse Hessian matrix
... | [
"private",
"boolean",
"computeSearchDirection",
"(",
")",
"{",
"// Compute the function's gradient",
"function",
".",
"computeGradient",
"(",
"temp0_Nx1",
".",
"data",
")",
";",
"// compute the change in gradient",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | Computes the next search direction using BFGS | [
"Computes",
"the",
"next",
"search",
"direction",
"using",
"BFGS"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java#L213-L252 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java | QuasiNewtonBFGS.resetMatrixB | private void resetMatrixB() {
// find the magnitude of the largest diagonal element
double maxDiag = 0;
for( int i = 0; i < N; i++ ) {
double d = Math.abs(B.get(i,i));
if( d > maxDiag )
maxDiag = d;
}
B.zero();
for( int i = 0; i < N; i++ ) {
B.set(i,i,maxDiag);
}
} | java | private void resetMatrixB() {
// find the magnitude of the largest diagonal element
double maxDiag = 0;
for( int i = 0; i < N; i++ ) {
double d = Math.abs(B.get(i,i));
if( d > maxDiag )
maxDiag = d;
}
B.zero();
for( int i = 0; i < N; i++ ) {
B.set(i,i,maxDiag);
}
} | [
"private",
"void",
"resetMatrixB",
"(",
")",
"{",
"// find the magnitude of the largest diagonal element",
"double",
"maxDiag",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"double",
"d",
"=",
"Math",
"."... | This is a total hack. Set B to a diagonal matrix where each diagonal element
is the value of the largest absolute value in B. This will be SPD and hopefully
not screw up the search. | [
"This",
"is",
"a",
"total",
"hack",
".",
"Set",
"B",
"to",
"a",
"diagonal",
"matrix",
"where",
"each",
"diagonal",
"element",
"is",
"the",
"value",
"of",
"the",
"largest",
"absolute",
"value",
"in",
"B",
".",
"This",
"will",
"be",
"SPD",
"and",
"hopefu... | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java#L259-L272 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java | QuasiNewtonBFGS.performLineSearch | private boolean performLineSearch() {
// if true then it can't iterate any more
if( lineSearch.iterate() ) {
// see if the line search failed
if( !lineSearch.isConverged() ) {
if( firstStep ) {
// if it failed on the very first step then it might have been too large
// try halving the step size
... | java | private boolean performLineSearch() {
// if true then it can't iterate any more
if( lineSearch.iterate() ) {
// see if the line search failed
if( !lineSearch.isConverged() ) {
if( firstStep ) {
// if it failed on the very first step then it might have been too large
// try halving the step size
... | [
"private",
"boolean",
"performLineSearch",
"(",
")",
"{",
"// if true then it can't iterate any more",
"if",
"(",
"lineSearch",
".",
"iterate",
"(",
")",
")",
"{",
"// see if the line search failed",
"if",
"(",
"!",
"lineSearch",
".",
"isConverged",
"(",
")",
")",
... | Performs a 1-D line search along the chosen direction until the Wolfe conditions
have been meet.
@return true if the search has terminated. | [
"Performs",
"a",
"1",
"-",
"D",
"line",
"search",
"along",
"the",
"chosen",
"direction",
"until",
"the",
"Wolfe",
"conditions",
"have",
"been",
"meet",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/quasinewton/QuasiNewtonBFGS.java#L312-L380 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/fitting/modelset/distance/FitByMeanStatistics.java | FitByMeanStatistics.computeMean | private void computeMean() {
meanError = 0;
int size = allPoints.size();
for (PointIndex<Point> inlier : allPoints) {
Point pt = inlier.data;
meanError += modelError.computeDistance(pt);
}
meanError /= size;
} | java | private void computeMean() {
meanError = 0;
int size = allPoints.size();
for (PointIndex<Point> inlier : allPoints) {
Point pt = inlier.data;
meanError += modelError.computeDistance(pt);
}
meanError /= size;
} | [
"private",
"void",
"computeMean",
"(",
")",
"{",
"meanError",
"=",
"0",
";",
"int",
"size",
"=",
"allPoints",
".",
"size",
"(",
")",
";",
"for",
"(",
"PointIndex",
"<",
"Point",
">",
"inlier",
":",
"allPoints",
")",
"{",
"Point",
"pt",
"=",
"inlier",... | Computes the mean and standard deviation of the points from the model | [
"Computes",
"the",
"mean",
"and",
"standard",
"deviation",
"of",
"the",
"points",
"from",
"the",
"model"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/fitting/modelset/distance/FitByMeanStatistics.java#L88-L100 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java | TrustRegionBase_F64.initialize | public void initialize(double initial[] , int numberOfParameters , double minimumFunctionValue ) {
super.initialize(initial,numberOfParameters);
tmp_p.reshape(numberOfParameters,1);
regionRadius = config.regionInitial;
fx = cost(x);
if( verbose != null ) {
verbose.println("Steps fx change ... | java | public void initialize(double initial[] , int numberOfParameters , double minimumFunctionValue ) {
super.initialize(initial,numberOfParameters);
tmp_p.reshape(numberOfParameters,1);
regionRadius = config.regionInitial;
fx = cost(x);
if( verbose != null ) {
verbose.println("Steps fx change ... | [
"public",
"void",
"initialize",
"(",
"double",
"initial",
"[",
"]",
",",
"int",
"numberOfParameters",
",",
"double",
"minimumFunctionValue",
")",
"{",
"super",
".",
"initialize",
"(",
"initial",
",",
"numberOfParameters",
")",
";",
"tmp_p",
".",
"reshape",
"("... | Specifies initial state of the search and completion criteria
@param initial Initial parameter state
@param numberOfParameters Number many parameters are being optimized.
@param minimumFunctionValue The minimum possible value that the function can output | [
"Specifies",
"initial",
"state",
"of",
"the",
"search",
"and",
"completion",
"criteria"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java#L91-L117 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java | TrustRegionBase_F64.updateDerivates | @Override
protected boolean updateDerivates() {
functionGradientHessian(x,sameStateAsCost,gradient,hessian);
if( config.hessianScaling ) {
computeHessianScaling();
applyHessianScaling();
}
// Convergence should be tested on scaled variables to remove their arbitrary natural scale
// from influencing ... | java | @Override
protected boolean updateDerivates() {
functionGradientHessian(x,sameStateAsCost,gradient,hessian);
if( config.hessianScaling ) {
computeHessianScaling();
applyHessianScaling();
}
// Convergence should be tested on scaled variables to remove their arbitrary natural scale
// from influencing ... | [
"@",
"Override",
"protected",
"boolean",
"updateDerivates",
"(",
")",
"{",
"functionGradientHessian",
"(",
"x",
",",
"sameStateAsCost",
",",
"gradient",
",",
"hessian",
")",
";",
"if",
"(",
"config",
".",
"hessianScaling",
")",
"{",
"computeHessianScaling",
"(",... | Computes all the derived data structures and attempts to update the parameters
@return true if it has converged. | [
"Computes",
"all",
"the",
"derived",
"data",
"structures",
"and",
"attempts",
"to",
"update",
"the",
"parameters"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java#L123-L147 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java | TrustRegionBase_F64.computeStep | @Override
protected boolean computeStep() {
// If first iteration and automatic
if( regionRadius == -1 ) {
// user has selected unconstrained method for initial step size
parameterUpdate.computeUpdate(p, Double.MAX_VALUE);
regionRadius = parameterUpdate.getStepLength();
if( regionRadius == Double.MAX_... | java | @Override
protected boolean computeStep() {
// If first iteration and automatic
if( regionRadius == -1 ) {
// user has selected unconstrained method for initial step size
parameterUpdate.computeUpdate(p, Double.MAX_VALUE);
regionRadius = parameterUpdate.getStepLength();
if( regionRadius == Double.MAX_... | [
"@",
"Override",
"protected",
"boolean",
"computeStep",
"(",
")",
"{",
"// If first iteration and automatic",
"if",
"(",
"regionRadius",
"==",
"-",
"1",
")",
"{",
"// user has selected unconstrained method for initial step size",
"parameterUpdate",
".",
"computeUpdate",
"("... | Changes the trust region's size and attempts to do a step again
@return true if it has converged. | [
"Changes",
"the",
"trust",
"region",
"s",
"size",
"and",
"attempts",
"to",
"do",
"a",
"step",
"again"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java#L153-L199 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java | TrustRegionBase_F64.considerCandidate | protected boolean considerCandidate(double fx_candidate, double fx_prev,
double predictedReduction, double stepLength ) {
// compute model prediction accuracy
double actualReduction = fx_prev-fx_candidate;
if( actualReduction == 0 || predictedReduction == 0 ) {
if( verbose != null )
verbose.pr... | java | protected boolean considerCandidate(double fx_candidate, double fx_prev,
double predictedReduction, double stepLength ) {
// compute model prediction accuracy
double actualReduction = fx_prev-fx_candidate;
if( actualReduction == 0 || predictedReduction == 0 ) {
if( verbose != null )
verbose.pr... | [
"protected",
"boolean",
"considerCandidate",
"(",
"double",
"fx_candidate",
",",
"double",
"fx_prev",
",",
"double",
"predictedReduction",
",",
"double",
"stepLength",
")",
"{",
"// compute model prediction accuracy",
"double",
"actualReduction",
"=",
"fx_prev",
"-",
"f... | Consider updating the system with the change in state p. The update will never
be accepted if the cost function increases.
@param fx_candidate Actual score at the candidate 'x'
@param fx_prev Score at the current 'x'
@param predictedReduction Reduction in score predicted by quadratic model
@param stepLength The lengt... | [
"Consider",
"updating",
"the",
"system",
"with",
"the",
"change",
"in",
"state",
"p",
".",
"The",
"update",
"will",
"never",
"be",
"accepted",
"if",
"the",
"cost",
"function",
"increases",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/trustregion/TrustRegionBase_F64.java#L235-L274 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java | LevenbergMarquardt_F64.initialize | public void initialize(double initial[] , int numberOfParameters , int numberOfFunctions ) {
super.initialize(initial,numberOfParameters);
lambda = config.dampeningInitial;
nu = NU_INITIAL;
residuals.reshape(numberOfFunctions,1);
diagOrig.reshape(numberOfParameters,1);
diagStep.reshape(numberOfParameters,... | java | public void initialize(double initial[] , int numberOfParameters , int numberOfFunctions ) {
super.initialize(initial,numberOfParameters);
lambda = config.dampeningInitial;
nu = NU_INITIAL;
residuals.reshape(numberOfFunctions,1);
diagOrig.reshape(numberOfParameters,1);
diagStep.reshape(numberOfParameters,... | [
"public",
"void",
"initialize",
"(",
"double",
"initial",
"[",
"]",
",",
"int",
"numberOfParameters",
",",
"int",
"numberOfFunctions",
")",
"{",
"super",
".",
"initialize",
"(",
"initial",
",",
"numberOfParameters",
")",
";",
"lambda",
"=",
"config",
".",
"d... | Initializes the search.
@param initial Initial state
@param numberOfParameters number of parameters
@param numberOfFunctions number of functions | [
"Initializes",
"the",
"search",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java#L113-L133 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java | LevenbergMarquardt_F64.computeStep | @Override
protected boolean computeStep() {
// compute the new location and it's score
if( !computeStep(lambda,gradient,p) ) {
if( config.mixture == 0.0 ) {
throw new OptimizationException("Singular matrix encountered. Try setting mixture to a non-zero value");
}
lambda *= 4;
if( verbose != null )... | java | @Override
protected boolean computeStep() {
// compute the new location and it's score
if( !computeStep(lambda,gradient,p) ) {
if( config.mixture == 0.0 ) {
throw new OptimizationException("Singular matrix encountered. Try setting mixture to a non-zero value");
}
lambda *= 4;
if( verbose != null )... | [
"@",
"Override",
"protected",
"boolean",
"computeStep",
"(",
")",
"{",
"// compute the new location and it's score",
"if",
"(",
"!",
"computeStep",
"(",
"lambda",
",",
"gradient",
",",
"p",
")",
")",
"{",
"if",
"(",
"config",
".",
"mixture",
"==",
"0.0",
")"... | Compute a new possible state and determine if it should be accepted or not. If accepted update the state
@return true if it has converged or false if it has not | [
"Compute",
"a",
"new",
"possible",
"state",
"and",
"determine",
"if",
"it",
"should",
"be",
"accepted",
"or",
"not",
".",
"If",
"accepted",
"update",
"the",
"state"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java#L165-L201 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java | LevenbergMarquardt_F64.processStepResults | private boolean processStepResults(double fx_candidate, double actualReduction, double predictedReduction) {
double ratio = actualReduction/predictedReduction;
boolean accepted;
// Accept the new state if the score improved
if( fx_candidate < fx ) {
// reduce the amount of dampening. Magic equation from [1... | java | private boolean processStepResults(double fx_candidate, double actualReduction, double predictedReduction) {
double ratio = actualReduction/predictedReduction;
boolean accepted;
// Accept the new state if the score improved
if( fx_candidate < fx ) {
// reduce the amount of dampening. Magic equation from [1... | [
"private",
"boolean",
"processStepResults",
"(",
"double",
"fx_candidate",
",",
"double",
"actualReduction",
",",
"double",
"predictedReduction",
")",
"{",
"double",
"ratio",
"=",
"actualReduction",
"/",
"predictedReduction",
";",
"boolean",
"accepted",
";",
"// Accep... | Sees if this is an improvement worth accepting. Adjust dampening parameter and change
the state if accepted.
@return true if it has converged or false if it has not | [
"Sees",
"if",
"this",
"is",
"an",
"improvement",
"worth",
"accepting",
".",
"Adjust",
"dampening",
"parameter",
"and",
"change",
"the",
"state",
"if",
"accepted",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java#L209-L244 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java | LevenbergMarquardt_F64.acceptNewState | private void acceptNewState( double fx_candidate ) {
DMatrixRMaj tmp = x;
x = x_next;
x_next = tmp;
fx = fx_candidate;
mode = Mode.COMPUTE_DERIVATIVES;
} | java | private void acceptNewState( double fx_candidate ) {
DMatrixRMaj tmp = x;
x = x_next;
x_next = tmp;
fx = fx_candidate;
mode = Mode.COMPUTE_DERIVATIVES;
} | [
"private",
"void",
"acceptNewState",
"(",
"double",
"fx_candidate",
")",
"{",
"DMatrixRMaj",
"tmp",
"=",
"x",
";",
"x",
"=",
"x_next",
";",
"x_next",
"=",
"tmp",
";",
"fx",
"=",
"fx_candidate",
";",
"mode",
"=",
"Mode",
".",
"COMPUTE_DERIVATIVES",
";",
"... | The new state has been accepted. Switch the internal state over to this
@param fx_candidate The new state | [
"The",
"new",
"state",
"has",
"been",
"accepted",
".",
"Switch",
"the",
"internal",
"state",
"over",
"to",
"this"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java#L250-L258 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java | LevenbergMarquardt_F64.computeStep | protected boolean computeStep( double lambda, DMatrixRMaj gradient , DMatrixRMaj step ) {
final double mixture = config.mixture;
for (int i = 0; i < diagOrig.numRows; i++) {
double v = min(config.diagonal_max, max(config.diagonal_min,diagOrig.data[i]));
diagStep.data[i] = v + lambda*(mixture + (1.0-mixture)*... | java | protected boolean computeStep( double lambda, DMatrixRMaj gradient , DMatrixRMaj step ) {
final double mixture = config.mixture;
for (int i = 0; i < diagOrig.numRows; i++) {
double v = min(config.diagonal_max, max(config.diagonal_min,diagOrig.data[i]));
diagStep.data[i] = v + lambda*(mixture + (1.0-mixture)*... | [
"protected",
"boolean",
"computeStep",
"(",
"double",
"lambda",
",",
"DMatrixRMaj",
"gradient",
",",
"DMatrixRMaj",
"step",
")",
"{",
"final",
"double",
"mixture",
"=",
"config",
".",
"mixture",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"diag... | Adjusts the Hessian's diagonal elements value and computes the next step
@param lambda (Input) tuning
@param gradient (Input) gradient
@param step (Output) step
@return true if solver could compute the next step | [
"Adjusts",
"the",
"Hessian",
"s",
"diagonal",
"elements",
"value",
"and",
"computes",
"the",
"next",
"step"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/lm/LevenbergMarquardt_F64.java#L291-L312 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/Polynomial.java | Polynomial.evaluate | public double evaluate( double variable ) {
if( size == 0 ) {
return 0;
} else if( size == 1 ) {
return c[0];
} else if( Double.isInfinite(variable)) {
// Only the largest power with a non-zero coefficient needs to be evaluated
int degree = computeDegree();
if( degree%2 == 0 )
variable = Doub... | java | public double evaluate( double variable ) {
if( size == 0 ) {
return 0;
} else if( size == 1 ) {
return c[0];
} else if( Double.isInfinite(variable)) {
// Only the largest power with a non-zero coefficient needs to be evaluated
int degree = computeDegree();
if( degree%2 == 0 )
variable = Doub... | [
"public",
"double",
"evaluate",
"(",
"double",
"variable",
")",
"{",
"if",
"(",
"size",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"size",
"==",
"1",
")",
"{",
"return",
"c",
"[",
"0",
"]",
";",
"}",
"else",
"if",
"(",
"... | Computes the polynomials output given the variable value Can handle infinite numbers
@return Output | [
"Computes",
"the",
"polynomials",
"output",
"given",
"the",
"variable",
"value",
"Can",
"handle",
"infinite",
"numbers"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/Polynomial.java#L74-L103 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/Polynomial.java | Polynomial.isIdentical | public boolean isIdentical( Polynomial p , double tol ) {
int m = Math.max(p.size(), size());
// make sure trailing coefficients are close to zero
for( int i = p.size; i < m; i++ ) {
if( Math.abs(c[i]) > tol ) {
return false;
}
}
for( int i = size; i < m; i++ ) {
if( Math.abs(p.c[i]) > tol ) {
... | java | public boolean isIdentical( Polynomial p , double tol ) {
int m = Math.max(p.size(), size());
// make sure trailing coefficients are close to zero
for( int i = p.size; i < m; i++ ) {
if( Math.abs(c[i]) > tol ) {
return false;
}
}
for( int i = size; i < m; i++ ) {
if( Math.abs(p.c[i]) > tol ) {
... | [
"public",
"boolean",
"isIdentical",
"(",
"Polynomial",
"p",
",",
"double",
"tol",
")",
"{",
"int",
"m",
"=",
"Math",
".",
"max",
"(",
"p",
".",
"size",
"(",
")",
",",
"size",
"(",
")",
")",
";",
"// make sure trailing coefficients are close to zero",
"for"... | Checks to see if the coefficients of two polynomials are identical to within tolerance. If the lengths
of the polynomials are not the same then the extra coefficients in the longer polynomial must be within tolerance
of zero.
@param p Polynomial that this polynomial is being compared against.
@param tol Similarity to... | [
"Checks",
"to",
"see",
"if",
"the",
"coefficients",
"of",
"two",
"polynomials",
"are",
"identical",
"to",
"within",
"tolerance",
".",
"If",
"the",
"lengths",
"of",
"the",
"polynomials",
"are",
"not",
"the",
"same",
"then",
"the",
"extra",
"coefficients",
"in... | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/Polynomial.java#L154-L179 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/Polynomial.java | Polynomial.truncateZeros | public void truncateZeros( double tol ) {
// double max = 0;
// for( int i = 0; i < size; i++ ) {
// double d = Math.abs(c[i]);
// if( d > max )
// max = d;
// }
//
// tol *= max;
int i = size-1;
for( ; i >= 0; i-- ) {
if( Math.abs(c[i]) > tol )
break;
}
size = i+1;
} | java | public void truncateZeros( double tol ) {
// double max = 0;
// for( int i = 0; i < size; i++ ) {
// double d = Math.abs(c[i]);
// if( d > max )
// max = d;
// }
//
// tol *= max;
int i = size-1;
for( ; i >= 0; i-- ) {
if( Math.abs(c[i]) > tol )
break;
}
size = i+1;
} | [
"public",
"void",
"truncateZeros",
"(",
"double",
"tol",
")",
"{",
"//\t\tdouble max = 0;",
"//\t\tfor( int i = 0; i < size; i++ ) {",
"//\t\t\tdouble d = Math.abs(c[i]);",
"//\t\t\tif( d > max )",
"//\t\t\t\tmax = d;",
"//\t\t}",
"//",
"//\t\ttol *= max;",
"int",
"i",
"=",
"si... | Prunes zero coefficients from the end of a sequence. A coefficient is zero if its absolute value
is less than or equal to tolerance.
@param tol Tolerance for zero. Try 1e-15 | [
"Prunes",
"zero",
"coefficients",
"from",
"the",
"end",
"of",
"a",
"sequence",
".",
"A",
"coefficient",
"is",
"zero",
"if",
"its",
"absolute",
"value",
"is",
"less",
"than",
"or",
"equal",
"to",
"tolerance",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/Polynomial.java#L187-L205 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java | KdTreeSearchNStandard.findNeighbor | @Override
public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) {
if( searchN <= 0 )
throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors.");
if( tree.root == null )
return;
this.searchN = searchN;
this.target = target;
... | java | @Override
public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) {
if( searchN <= 0 )
throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors.");
if( tree.root == null )
return;
this.searchN = searchN;
this.target = target;
... | [
"@",
"Override",
"public",
"void",
"findNeighbor",
"(",
"P",
"target",
",",
"int",
"searchN",
",",
"FastQueue",
"<",
"KdTreeResult",
">",
"results",
")",
"{",
"if",
"(",
"searchN",
"<=",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"I'm sorry... | Finds the nodes which are closest to 'target' and within range of the maximum distance.
@param target A point
@param searchN Number of nearest-neighbors it will search for
@param results Storage for the found neighbors | [
"Finds",
"the",
"nodes",
"which",
"are",
"closest",
"to",
"target",
"and",
"within",
"range",
"of",
"the",
"maximum",
"distance",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java#L79-L92 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java | KdTreeSearchNStandard.checkBestDistance | private void checkBestDistance(KdTree.Node node, FastQueue<KdTreeResult> neighbors) {
double distSq = distance.distance((P)node.point,target);
// <= because multiple nodes could be at the bestDistanceSq
if( distSq <= mostDistantNeighborSq) {
if( neighbors.size() < searchN ) {
// the list of nearest neighbo... | java | private void checkBestDistance(KdTree.Node node, FastQueue<KdTreeResult> neighbors) {
double distSq = distance.distance((P)node.point,target);
// <= because multiple nodes could be at the bestDistanceSq
if( distSq <= mostDistantNeighborSq) {
if( neighbors.size() < searchN ) {
// the list of nearest neighbo... | [
"private",
"void",
"checkBestDistance",
"(",
"KdTree",
".",
"Node",
"node",
",",
"FastQueue",
"<",
"KdTreeResult",
">",
"neighbors",
")",
"{",
"double",
"distSq",
"=",
"distance",
".",
"distance",
"(",
"(",
"P",
")",
"node",
".",
"point",
",",
"target",
... | See if the node being considered is a new nearest-neighbor | [
"See",
"if",
"the",
"node",
"being",
"considered",
"is",
"a",
"new",
"nearest",
"-",
"neighbor"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java#L137-L184 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/gmm/ExpectationMaximizationGmm_F64.java | ExpectationMaximizationGmm_F64.expectation | protected double expectation() {
double sumChiSq = 0;
for (int i = 0; i < info.size(); i++) {
PointInfo p = info.get(i);
// identify the best cluster match and save it's chi-square for convergence testing
double bestLikelihood = 0;
double bestChiSq = Double.MAX_VALUE;
double total = 0;
for (int... | java | protected double expectation() {
double sumChiSq = 0;
for (int i = 0; i < info.size(); i++) {
PointInfo p = info.get(i);
// identify the best cluster match and save it's chi-square for convergence testing
double bestLikelihood = 0;
double bestChiSq = Double.MAX_VALUE;
double total = 0;
for (int... | [
"protected",
"double",
"expectation",
"(",
")",
"{",
"double",
"sumChiSq",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"info",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"PointInfo",
"p",
"=",
"info",
".",
"get",
"(",
... | For each point compute the "responsibility" for each Gaussian
@return The sum of chi-square. Can be used to estimate the total error. | [
"For",
"each",
"point",
"compute",
"the",
"responsibility",
"for",
"each",
"Gaussian"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/ExpectationMaximizationGmm_F64.java#L155-L190 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/clustering/gmm/ExpectationMaximizationGmm_F64.java | ExpectationMaximizationGmm_F64.maximization | protected void maximization() {
// discard previous parameters by zeroing
for (int i = 0; i < mixture.size; i++) {
mixture.get(i).zero();
}
// compute the new mean
for (int i = 0; i < info.size; i++) {
PointInfo p = info.get(i);
for (int j = 0; j < mixture.size; j++) {
mixture.get(j).addMean(p.... | java | protected void maximization() {
// discard previous parameters by zeroing
for (int i = 0; i < mixture.size; i++) {
mixture.get(i).zero();
}
// compute the new mean
for (int i = 0; i < info.size; i++) {
PointInfo p = info.get(i);
for (int j = 0; j < mixture.size; j++) {
mixture.get(j).addMean(p.... | [
"protected",
"void",
"maximization",
"(",
")",
"{",
"// discard previous parameters by zeroing",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mixture",
".",
"size",
";",
"i",
"++",
")",
"{",
"mixture",
".",
"get",
"(",
"i",
")",
".",
"zero",
"(",
... | Using points responsibility information to recompute the Gaussians and their weights, maximizing
the likelihood of the mixture. | [
"Using",
"points",
"responsibility",
"information",
"to",
"recompute",
"the",
"Gaussians",
"and",
"their",
"weights",
"maximizing",
"the",
"likelihood",
"of",
"the",
"mixture",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/clustering/gmm/ExpectationMaximizationGmm_F64.java#L196-L244 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/FitQuadratic1D.java | FitQuadratic1D.process | public boolean process( int offset , int length , double ...data ) {
if( data.length < 3 )
throw new IllegalArgumentException("At least three points");
A.reshape(data.length,3);
y.reshape(data.length,1);
int indexDst = 0;
int indexSrc = offset;
for( int i = 0; i < length; i++ ) {
double d = data[ind... | java | public boolean process( int offset , int length , double ...data ) {
if( data.length < 3 )
throw new IllegalArgumentException("At least three points");
A.reshape(data.length,3);
y.reshape(data.length,1);
int indexDst = 0;
int indexSrc = offset;
for( int i = 0; i < length; i++ ) {
double d = data[ind... | [
"public",
"boolean",
"process",
"(",
"int",
"offset",
",",
"int",
"length",
",",
"double",
"...",
"data",
")",
"{",
"if",
"(",
"data",
".",
"length",
"<",
"3",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"At least three points\"",
")",
";",
"A"... | Computes polynomial coefficients for the given data.
@param length Number of elements in data with relevant data.
@param data Set of observation data.
@return true if successful or false if it fails. | [
"Computes",
"polynomial",
"coefficients",
"for",
"the",
"given",
"data",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/FitQuadratic1D.java#L52-L77 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/math/HessianSchurComplement_Base.java | HessianSchurComplement_Base.innerVectorHessian | @Override
public double innerVectorHessian( DMatrixRMaj v ) {
int M = A.getNumRows();
double sum = 0;
sum += innerProduct(v.data, 0, A, v.data, 0);
sum += 2*innerProduct(v.data, 0, B, v.data, M);
sum += innerProduct(v.data, M, D, v.data, M);
return sum;
} | java | @Override
public double innerVectorHessian( DMatrixRMaj v ) {
int M = A.getNumRows();
double sum = 0;
sum += innerProduct(v.data, 0, A, v.data, 0);
sum += 2*innerProduct(v.data, 0, B, v.data, M);
sum += innerProduct(v.data, M, D, v.data, M);
return sum;
} | [
"@",
"Override",
"public",
"double",
"innerVectorHessian",
"(",
"DMatrixRMaj",
"v",
")",
"{",
"int",
"M",
"=",
"A",
".",
"getNumRows",
"(",
")",
";",
"double",
"sum",
"=",
"0",
";",
"sum",
"+=",
"innerProduct",
"(",
"v",
".",
"data",
",",
"0",
",",
... | Vector matrix inner product of Hessian in block format.
<p>
[A B;C D]*[x;y] = [c;d]<br>
A*x + B*y = c<br>
C*x + D*y = d<br>
[x;y]<sup>T</sup>[A B;C D]*[x;y] = [x;y]<sup>T</sup>*[c;d]<br>
</p>
@param v row vector
@return v'*H*v = v'*[A B;C D]*v | [
"Vector",
"matrix",
"inner",
"product",
"of",
"Hessian",
"in",
"block",
"format",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/math/HessianSchurComplement_Base.java#L97-L107 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/math/HessianSchurComplement_Base.java | HessianSchurComplement_Base.computeGradient | @Override
public void computeGradient(S jacLeft , S jacRight ,
DMatrixRMaj residuals, DMatrixRMaj gradient) {
// Find the gradient using the two matrices for Jacobian
// g = J'*r = [L,R]'*r
x1.reshape(jacLeft.getNumCols(),1);
x2.reshape(jacRight.getNumCols(),1);
multTransA(jacLeft,residuals,x1);
m... | java | @Override
public void computeGradient(S jacLeft , S jacRight ,
DMatrixRMaj residuals, DMatrixRMaj gradient) {
// Find the gradient using the two matrices for Jacobian
// g = J'*r = [L,R]'*r
x1.reshape(jacLeft.getNumCols(),1);
x2.reshape(jacRight.getNumCols(),1);
multTransA(jacLeft,residuals,x1);
m... | [
"@",
"Override",
"public",
"void",
"computeGradient",
"(",
"S",
"jacLeft",
",",
"S",
"jacRight",
",",
"DMatrixRMaj",
"residuals",
",",
"DMatrixRMaj",
"gradient",
")",
"{",
"// Find the gradient using the two matrices for Jacobian",
"// g = J'*r = [L,R]'*r",
"x1",
".",
"... | Computes the gradient using Schur complement
@param jacLeft (Input) Left side of Jacobian
@param jacRight (Input) Right side of Jacobian
@param residuals (Input) Residuals
@param gradient (Output) Gradient | [
"Computes",
"the",
"gradient",
"using",
"Schur",
"complement"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/math/HessianSchurComplement_Base.java#L200-L213 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.buildFromPoints | private Node buildFromPoints(int lower, int upper) {
if (upper == lower) {
return null;
}
final Node node = new Node();
node.index = lower;
if (upper - lower > 1) {
// choose an arbitrary vantage point and move it to the start
int i = random.nextInt(upper - lower - 1) + lower;
listS... | java | private Node buildFromPoints(int lower, int upper) {
if (upper == lower) {
return null;
}
final Node node = new Node();
node.index = lower;
if (upper - lower > 1) {
// choose an arbitrary vantage point and move it to the start
int i = random.nextInt(upper - lower - 1) + lower;
listS... | [
"private",
"Node",
"buildFromPoints",
"(",
"int",
"lower",
",",
"int",
"upper",
")",
"{",
"if",
"(",
"upper",
"==",
"lower",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Node",
"node",
"=",
"new",
"Node",
"(",
")",
";",
"node",
".",
"index",
"="... | Builds the tree from a set of points by recursively partitioning
them according to a random pivot.
@param lower start of range
@param upper end of range (exclusive)
@return root of the tree or null if lower == upper | [
"Builds",
"the",
"tree",
"from",
"a",
"set",
"of",
"points",
"by",
"recursively",
"partitioning",
"them",
"according",
"to",
"a",
"random",
"pivot",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L93-L123 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.nthElement | private void nthElement(int left, int right, int n, double[] origin) {
int npos = partitionItems(left, right, n, origin);
if (npos < n)
nthElement(npos + 1, right, n, origin);
if (npos > n)
nthElement(left, npos, n, origin);
} | java | private void nthElement(int left, int right, int n, double[] origin) {
int npos = partitionItems(left, right, n, origin);
if (npos < n)
nthElement(npos + 1, right, n, origin);
if (npos > n)
nthElement(left, npos, n, origin);
} | [
"private",
"void",
"nthElement",
"(",
"int",
"left",
",",
"int",
"right",
",",
"int",
"n",
",",
"double",
"[",
"]",
"origin",
")",
"{",
"int",
"npos",
"=",
"partitionItems",
"(",
"left",
",",
"right",
",",
"n",
",",
"origin",
")",
";",
"if",
"(",
... | Ensures that the n-th element is in a correct position in the list based on
the distance from origin.
@param left start of range
@param right end of range (exclusive)
@param n element to put in the right position
@param origin origin to compute the distance to | [
"Ensures",
"that",
"the",
"n",
"-",
"th",
"element",
"is",
"in",
"a",
"correct",
"position",
"in",
"the",
"list",
"based",
"on",
"the",
"distance",
"from",
"origin",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L133-L139 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.partitionItems | private int partitionItems(int left, int right, int pivot, double[] origin) {
double pivotDistance = distance(origin, items[pivot]);
listSwap(items, pivot, right - 1);
listSwap(indexes, pivot, right - 1);
int storeIndex = left;
for (int i = left; i < right - 1; i++) {
if (distance(origin, items[i]) <... | java | private int partitionItems(int left, int right, int pivot, double[] origin) {
double pivotDistance = distance(origin, items[pivot]);
listSwap(items, pivot, right - 1);
listSwap(indexes, pivot, right - 1);
int storeIndex = left;
for (int i = left; i < right - 1; i++) {
if (distance(origin, items[i]) <... | [
"private",
"int",
"partitionItems",
"(",
"int",
"left",
",",
"int",
"right",
",",
"int",
"pivot",
",",
"double",
"[",
"]",
"origin",
")",
"{",
"double",
"pivotDistance",
"=",
"distance",
"(",
"origin",
",",
"items",
"[",
"pivot",
"]",
")",
";",
"listSw... | Partition the points based on their distance to origin around the selected pivot.
@param left range start
@param right range end (exclusive)
@param pivot pivot for the partition
@param origin origin to compute the distance to
@return index of the pivot | [
"Partition",
"the",
"points",
"based",
"on",
"their",
"distance",
"to",
"origin",
"around",
"the",
"selected",
"pivot",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L149-L164 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.listSwap | private <E> void listSwap(E[] list, int a, int b) {
final E tmp = list[a];
list[a] = list[b];
list[b] = tmp;
} | java | private <E> void listSwap(E[] list, int a, int b) {
final E tmp = list[a];
list[a] = list[b];
list[b] = tmp;
} | [
"private",
"<",
"E",
">",
"void",
"listSwap",
"(",
"E",
"[",
"]",
"list",
",",
"int",
"a",
",",
"int",
"b",
")",
"{",
"final",
"E",
"tmp",
"=",
"list",
"[",
"a",
"]",
";",
"list",
"[",
"a",
"]",
"=",
"list",
"[",
"b",
"]",
";",
"list",
"[... | Swaps two items in the given list.
@param list list to swap the items in
@param a index of the first item
@param b index of the second item
@param <E> list type | [
"Swaps",
"two",
"items",
"in",
"the",
"given",
"list",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L173-L177 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.distance | private static double distance(double[] p1, double[] p2) {
switch (p1.length) {
case 2: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]));
case 3: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]));... | java | private static double distance(double[] p1, double[] p2) {
switch (p1.length) {
case 2: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]));
case 3: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]));... | [
"private",
"static",
"double",
"distance",
"(",
"double",
"[",
"]",
"p1",
",",
"double",
"[",
"]",
"p2",
")",
"{",
"switch",
"(",
"p1",
".",
"length",
")",
"{",
"case",
"2",
":",
"return",
"Math",
".",
"sqrt",
"(",
"(",
"p1",
"[",
"0",
"]",
"-"... | Compute the Euclidean distance between p1 and p2.
@param p1 first point
@param p2 second point
@return Euclidean distance | [
"Compute",
"the",
"Euclidean",
"distance",
"between",
"p1",
"and",
"p2",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L191-L204 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.search | private PriorityQueue<HeapItem> search(final double[] target, double maxDistance, final int k) {
PriorityQueue<HeapItem> heap = new PriorityQueue<HeapItem>();
if (root == null) {
return heap;
}
double tau = maxDistance;
final FastQueue<Node> nodes = new FastQueue<Node>(20, Node.class, false);
no... | java | private PriorityQueue<HeapItem> search(final double[] target, double maxDistance, final int k) {
PriorityQueue<HeapItem> heap = new PriorityQueue<HeapItem>();
if (root == null) {
return heap;
}
double tau = maxDistance;
final FastQueue<Node> nodes = new FastQueue<Node>(20, Node.class, false);
no... | [
"private",
"PriorityQueue",
"<",
"HeapItem",
">",
"search",
"(",
"final",
"double",
"[",
"]",
"target",
",",
"double",
"maxDistance",
",",
"final",
"int",
"k",
")",
"{",
"PriorityQueue",
"<",
"HeapItem",
">",
"heap",
"=",
"new",
"PriorityQueue",
"<",
"Heap... | Recursively search for the k nearest neighbors to target.
@param target target point
@param maxDistance maximum distance
@param k number of neighbors to find | [
"Recursively",
"search",
"for",
"the",
"k",
"nearest",
"neighbors",
"to",
"target",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L212-L246 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/VpTree.java | VpTree.searchNearest | private boolean searchNearest(final double[] target, double maxDistance, NnData<double[]> result) {
if (root == null) {
return false;
}
double tau = maxDistance;
final FastQueue<Node> nodes = new FastQueue<Node>(20, Node.class, false);
nodes.add(root);
result.distance = Double.POSITIVE_INFINITY;... | java | private boolean searchNearest(final double[] target, double maxDistance, NnData<double[]> result) {
if (root == null) {
return false;
}
double tau = maxDistance;
final FastQueue<Node> nodes = new FastQueue<Node>(20, Node.class, false);
nodes.add(root);
result.distance = Double.POSITIVE_INFINITY;... | [
"private",
"boolean",
"searchNearest",
"(",
"final",
"double",
"[",
"]",
"target",
",",
"double",
"maxDistance",
",",
"NnData",
"<",
"double",
"[",
"]",
">",
"result",
")",
"{",
"if",
"(",
"root",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
... | Equivalent to the above search method to find one nearest neighbor.
It is faster as it does not need to allocate and use the heap data structure.
@param target target point
@param maxDistance maximum distance
@param result information about the nearest point (output parameter)
@return true if a nearest point was found ... | [
"Equivalent",
"to",
"the",
"above",
"search",
"method",
"to",
"find",
"one",
"nearest",
"neighbor",
".",
"It",
"is",
"faster",
"as",
"it",
"does",
"not",
"need",
"to",
"allocate",
"and",
"use",
"the",
"heap",
"data",
"structure",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/VpTree.java#L256-L290 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/searches/KdTreeSearch1Standard.java | KdTreeSearch1Standard.findNeighbor | @Override
public KdTree.Node findNeighbor(P target) {
if( tree.root == null )
return null;
this.target = target;
this.closest = null;
this.bestDistanceSq = maxDistanceSq;
stepClosest(tree.root);
return closest;
} | java | @Override
public KdTree.Node findNeighbor(P target) {
if( tree.root == null )
return null;
this.target = target;
this.closest = null;
this.bestDistanceSq = maxDistanceSq;
stepClosest(tree.root);
return closest;
} | [
"@",
"Override",
"public",
"KdTree",
".",
"Node",
"findNeighbor",
"(",
"P",
"target",
")",
"{",
"if",
"(",
"tree",
".",
"root",
"==",
"null",
")",
"return",
"null",
";",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"closest",
"=",
"null",
... | Finds the node which is closest to 'target'
@param target A point
@return Closest node or null if none is within the minimum distance. | [
"Finds",
"the",
"node",
"which",
"is",
"closest",
"to",
"target"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearch1Standard.java#L77-L89 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/impl/FindRealRootsSturm.java | FindRealRootsSturm.process | public void process( Polynomial poly ) {
sturm.initialize(poly);
if( searchRadius <= 0 )
numRoots = sturm.countRealRoots(Double.NEGATIVE_INFINITY,Double.POSITIVE_INFINITY);
else
numRoots = sturm.countRealRoots(-searchRadius,searchRadius);
if( numRoots == 0 )
return;
if( searchRadius <= 0 )
hand... | java | public void process( Polynomial poly ) {
sturm.initialize(poly);
if( searchRadius <= 0 )
numRoots = sturm.countRealRoots(Double.NEGATIVE_INFINITY,Double.POSITIVE_INFINITY);
else
numRoots = sturm.countRealRoots(-searchRadius,searchRadius);
if( numRoots == 0 )
return;
if( searchRadius <= 0 )
hand... | [
"public",
"void",
"process",
"(",
"Polynomial",
"poly",
")",
"{",
"sturm",
".",
"initialize",
"(",
"poly",
")",
";",
"if",
"(",
"searchRadius",
"<=",
"0",
")",
"numRoots",
"=",
"sturm",
".",
"countRealRoots",
"(",
"Double",
".",
"NEGATIVE_INFINITY",
",",
... | Find real roots for the specified polynomial.
@param poly Polynomial which has less than or equal to the number of coefficients specified in this class's
constructor. | [
"Find",
"real",
"roots",
"for",
"the",
"specified",
"polynomial",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/impl/FindRealRootsSturm.java#L112-L133 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/impl/FindRealRootsSturm.java | FindRealRootsSturm.handleAllRoots | private void handleAllRoots() {
int totalFound = 0;
double r = 1;
int iter = 0;
// increase the search region centered around 0 until at least one root has been found
while( iter++ < maxBoundIterations && (totalFound=sturm.countRealRoots(-r,r)) <= 0 ) {
r = 2*r*r;
}
if( Double.isInfinite(r) )
throw... | java | private void handleAllRoots() {
int totalFound = 0;
double r = 1;
int iter = 0;
// increase the search region centered around 0 until at least one root has been found
while( iter++ < maxBoundIterations && (totalFound=sturm.countRealRoots(-r,r)) <= 0 ) {
r = 2*r*r;
}
if( Double.isInfinite(r) )
throw... | [
"private",
"void",
"handleAllRoots",
"(",
")",
"{",
"int",
"totalFound",
"=",
"0",
";",
"double",
"r",
"=",
"1",
";",
"int",
"iter",
"=",
"0",
";",
"// increase the search region centered around 0 until at least one root has been found",
"while",
"(",
"iter",
"++",
... | Search for all real roots. First find a region about 0 which contains at least one root. Then search
above and below. | [
"Search",
"for",
"all",
"real",
"roots",
".",
"First",
"find",
"a",
"region",
"about",
"0",
"which",
"contains",
"at",
"least",
"one",
"root",
".",
"Then",
"search",
"above",
"and",
"below",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/impl/FindRealRootsSturm.java#L140-L195 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/impl/FindRealRootsSturm.java | FindRealRootsSturm.bisectionRoot | private void bisectionRoot( double l , double u , int index ) {
// use bisection until there is an estimate within tolerance
int iter = 0;
while( u-l > boundTolerance*Math.abs(l) && iter++ < maxBoundIterations) {
double m = (l+u)/2.0;
int numRoots = sturm.countRealRoots(m,u);
if( numRoots == 1 ) {
l ... | java | private void bisectionRoot( double l , double u , int index ) {
// use bisection until there is an estimate within tolerance
int iter = 0;
while( u-l > boundTolerance*Math.abs(l) && iter++ < maxBoundIterations) {
double m = (l+u)/2.0;
int numRoots = sturm.countRealRoots(m,u);
if( numRoots == 1 ) {
l ... | [
"private",
"void",
"bisectionRoot",
"(",
"double",
"l",
",",
"double",
"u",
",",
"int",
"index",
")",
"{",
"// use bisection until there is an estimate within tolerance",
"int",
"iter",
"=",
"0",
";",
"while",
"(",
"u",
"-",
"l",
">",
"boundTolerance",
"*",
"M... | Searches for a single real root inside the range. Only one root is assumed to be inside
@param l lower value of search range
@param u upper value of search range
@param index | [
"Searches",
"for",
"a",
"single",
"real",
"root",
"inside",
"the",
"range",
".",
"Only",
"one",
"root",
"is",
"assumed",
"to",
"be",
"inside"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/impl/FindRealRootsSturm.java#L204-L226 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/solver/impl/FindRealRootsSturm.java | FindRealRootsSturm.boundEachRoot | private void boundEachRoot( double l , double u , int startIndex , int numRoots ) {
// Find an upper and lower bound which contains one real root only
int iter = 0;
double allUpper = u;
int root = 0;
int lastFound = 0;
double lastUpper = u;
while( root < numRoots && iter++ < maxBoundIterations) {
doub... | java | private void boundEachRoot( double l , double u , int startIndex , int numRoots ) {
// Find an upper and lower bound which contains one real root only
int iter = 0;
double allUpper = u;
int root = 0;
int lastFound = 0;
double lastUpper = u;
while( root < numRoots && iter++ < maxBoundIterations) {
doub... | [
"private",
"void",
"boundEachRoot",
"(",
"double",
"l",
",",
"double",
"u",
",",
"int",
"startIndex",
",",
"int",
"numRoots",
")",
"{",
"// Find an upper and lower bound which contains one real root only",
"int",
"iter",
"=",
"0",
";",
"double",
"allUpper",
"=",
"... | Finds a crude upper and lower bound for each root that includes only one root.
NOTE: Performance could be improved with better book keeping. For example, if it knows a bound with
for two roots, then one for one root it then knows the bounds for both roots. | [
"Finds",
"a",
"crude",
"upper",
"and",
"lower",
"bound",
"for",
"each",
"root",
"that",
"includes",
"only",
"one",
"root",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/solver/impl/FindRealRootsSturm.java#L234-L273 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/GaussNewtonBase_F64.java | GaussNewtonBase_F64.iterate | public boolean iterate() {
boolean converged;
switch( mode ) {
case COMPUTE_DERIVATIVES:
totalFullSteps++;
converged = updateDerivates();
if( !converged ) {
totalSelectSteps++;
converged = computeStep();
}
break;
case DETERMINE_STEP:
totalSelectSteps++;
converged = compu... | java | public boolean iterate() {
boolean converged;
switch( mode ) {
case COMPUTE_DERIVATIVES:
totalFullSteps++;
converged = updateDerivates();
if( !converged ) {
totalSelectSteps++;
converged = computeStep();
}
break;
case DETERMINE_STEP:
totalSelectSteps++;
converged = compu... | [
"public",
"boolean",
"iterate",
"(",
")",
"{",
"boolean",
"converged",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"COMPUTE_DERIVATIVES",
":",
"totalFullSteps",
"++",
";",
"converged",
"=",
"updateDerivates",
"(",
")",
";",
"if",
"(",
"!",
"converged",
"... | Performs one iteration
@return true if it has converged or false if not | [
"Performs",
"one",
"iteration"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/GaussNewtonBase_F64.java#L110-L140 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/GaussNewtonBase_F64.java | GaussNewtonBase_F64.computeHessianScaling | public void computeHessianScaling(DMatrixRMaj scaling ) {
double max = 0;
for (int i = 0; i < scaling.numRows; i++) {
// mathematically it should never be negative but...
double v = scaling.data[i] = sqrt(abs(scaling.data[i]));
if( v > max )
max = v;
}
// Add this number to avoid divide by zero.
... | java | public void computeHessianScaling(DMatrixRMaj scaling ) {
double max = 0;
for (int i = 0; i < scaling.numRows; i++) {
// mathematically it should never be negative but...
double v = scaling.data[i] = sqrt(abs(scaling.data[i]));
if( v > max )
max = v;
}
// Add this number to avoid divide by zero.
... | [
"public",
"void",
"computeHessianScaling",
"(",
"DMatrixRMaj",
"scaling",
")",
"{",
"double",
"max",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scaling",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"// mathematically it should never be ... | Applies the standard formula for computing scaling. This is broken off into its own
function so that it easily invoked if the function above is overridden
@param scaling Vector containing scaling information | [
"Applies",
"the",
"standard",
"formula",
"for",
"computing",
"scaling",
".",
"This",
"is",
"broken",
"off",
"into",
"its",
"own",
"function",
"so",
"that",
"it",
"easily",
"invoked",
"if",
"the",
"function",
"above",
"is",
"overridden"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/GaussNewtonBase_F64.java#L169-L186 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/optimization/GaussNewtonBase_F64.java | GaussNewtonBase_F64.computePredictedReduction | public double computePredictedReduction( DMatrixRMaj p ) {
return -CommonOps_DDRM.dot(gradient,p) - 0.5*hessian.innerVectorHessian(p);
} | java | public double computePredictedReduction( DMatrixRMaj p ) {
return -CommonOps_DDRM.dot(gradient,p) - 0.5*hessian.innerVectorHessian(p);
} | [
"public",
"double",
"computePredictedReduction",
"(",
"DMatrixRMaj",
"p",
")",
"{",
"return",
"-",
"CommonOps_DDRM",
".",
"dot",
"(",
"gradient",
",",
"p",
")",
"-",
"0.5",
"*",
"hessian",
".",
"innerVectorHessian",
"(",
"p",
")",
";",
"}"
] | Computes predicted reduction for step 'p'
@param p Change in state or the step
@return predicted reduction in quadratic model | [
"Computes",
"predicted",
"reduction",
"for",
"step",
"p"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/optimization/GaussNewtonBase_F64.java#L240-L242 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/GrowQueue_I32.java | GrowQueue_I32.setTo | public void setTo( int[] array , int offset , int length ) {
resize(length);
System.arraycopy(array,offset,data,0,length);
} | java | public void setTo( int[] array , int offset , int length ) {
resize(length);
System.arraycopy(array,offset,data,0,length);
} | [
"public",
"void",
"setTo",
"(",
"int",
"[",
"]",
"array",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"resize",
"(",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"offset",
",",
"data",
",",
"0",
",",
"length",
")",
... | Sets this array to be equal to the array segment
@param array (Input) source array
@param offset first index
@param length number of elements to copy | [
"Sets",
"this",
"array",
"to",
"be",
"equal",
"to",
"the",
"array",
"segment"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I32.java#L138-L141 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/GrowQueue_I32.java | GrowQueue_I32.insert | public void insert( int index , int value ) {
if( size == data.length ) {
int temp[] = new int[ size * 2];
System.arraycopy(data,0,temp,0,index);
temp[index] = value;
System.arraycopy(data,index,temp,index+1,size-index);
this.data = temp;
size++;
} else {
size++;
for( int i = size-1; i > ind... | java | public void insert( int index , int value ) {
if( size == data.length ) {
int temp[] = new int[ size * 2];
System.arraycopy(data,0,temp,0,index);
temp[index] = value;
System.arraycopy(data,index,temp,index+1,size-index);
this.data = temp;
size++;
} else {
size++;
for( int i = size-1; i > ind... | [
"public",
"void",
"insert",
"(",
"int",
"index",
",",
"int",
"value",
")",
"{",
"if",
"(",
"size",
"==",
"data",
".",
"length",
")",
"{",
"int",
"temp",
"[",
"]",
"=",
"new",
"int",
"[",
"size",
"*",
"2",
"]",
";",
"System",
".",
"arraycopy",
"... | Inserts the value at the specified index and shifts all the other values down. | [
"Inserts",
"the",
"value",
"at",
"the",
"specified",
"index",
"and",
"shifts",
"all",
"the",
"other",
"values",
"down",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I32.java#L171-L186 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/struct/GrowQueue_I32.java | GrowQueue_I32.removeHead | public void removeHead( int total ) {
for( int j = total; j < size; j++ ) {
data[j-total] = data[j];
}
size -= total;
} | java | public void removeHead( int total ) {
for( int j = total; j < size; j++ ) {
data[j-total] = data[j];
}
size -= total;
} | [
"public",
"void",
"removeHead",
"(",
"int",
"total",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"total",
";",
"j",
"<",
"size",
";",
"j",
"++",
")",
"{",
"data",
"[",
"j",
"-",
"total",
"]",
"=",
"data",
"[",
"j",
"]",
";",
"}",
"size",
"-=",
"... | Removes the first 'total' elements from the queue. Element 'total' will be the new start of the queue
@param total Number of elements to remove from the head of the queue | [
"Removes",
"the",
"first",
"total",
"elements",
"from",
"the",
"queue",
".",
"Element",
"total",
"will",
"be",
"the",
"new",
"start",
"of",
"the",
"queue"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/struct/GrowQueue_I32.java#L193-L198 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/combinatorics/Permute.java | Permute.init | private void init( List<T> list ) {
this.list = list;
indexes = new int[ list.size() ];
counters = new int[ list.size() ];
for( int i = 0; i < indexes.length ; i++ ) {
counters[i] = indexes[i] = i;
}
total = 1;
for( int i = 2; i <= indexes.length ; i++ ) {
total *= i;
}
permutation = 0;
} | java | private void init( List<T> list ) {
this.list = list;
indexes = new int[ list.size() ];
counters = new int[ list.size() ];
for( int i = 0; i < indexes.length ; i++ ) {
counters[i] = indexes[i] = i;
}
total = 1;
for( int i = 2; i <= indexes.length ; i++ ) {
total *= i;
}
permutation = 0;
} | [
"private",
"void",
"init",
"(",
"List",
"<",
"T",
">",
"list",
")",
"{",
"this",
".",
"list",
"=",
"list",
";",
"indexes",
"=",
"new",
"int",
"[",
"list",
".",
"size",
"(",
")",
"]",
";",
"counters",
"=",
"new",
"int",
"[",
"list",
".",
"size",... | Initializes the permutation for a new list
@param list List which is to be permuted. | [
"Initializes",
"the",
"permutation",
"for",
"a",
"new",
"list"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Permute.java#L88-L103 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/combinatorics/Permute.java | Permute.next | public boolean next()
{
if( indexes.length <= 1 || permutation >= total-1 )
return false;
int N = indexes.length-2;
int k = N;
swap(k, counters[k]++);
while( counters[k] == indexes.length ) {
k -= 1;
swap(k, counters[k]++);
}
swap(counters[k], k); //before
while (k < indexes.length - 1) {
... | java | public boolean next()
{
if( indexes.length <= 1 || permutation >= total-1 )
return false;
int N = indexes.length-2;
int k = N;
swap(k, counters[k]++);
while( counters[k] == indexes.length ) {
k -= 1;
swap(k, counters[k]++);
}
swap(counters[k], k); //before
while (k < indexes.length - 1) {
... | [
"public",
"boolean",
"next",
"(",
")",
"{",
"if",
"(",
"indexes",
".",
"length",
"<=",
"1",
"||",
"permutation",
">=",
"total",
"-",
"1",
")",
"return",
"false",
";",
"int",
"N",
"=",
"indexes",
".",
"length",
"-",
"2",
";",
"int",
"k",
"=",
"N",... | This will permute the list once | [
"This",
"will",
"permute",
"the",
"list",
"once"
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Permute.java#L115-L136 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/combinatorics/Permute.java | Permute.previous | public boolean previous()
{
if( indexes.length <= 1 || permutation <= 0 )
return false;
int N = indexes.length-2;
int k = N;
while( counters[k] <= k ) {
k--;
}
swap(counters[k], k);
counters[k]--;
swap(k, counters[k]);
int foo = k+1;
while( counters[k+1] == k+1 && k < indexes.length-2) {
... | java | public boolean previous()
{
if( indexes.length <= 1 || permutation <= 0 )
return false;
int N = indexes.length-2;
int k = N;
while( counters[k] <= k ) {
k--;
}
swap(counters[k], k);
counters[k]--;
swap(k, counters[k]);
int foo = k+1;
while( counters[k+1] == k+1 && k < indexes.length-2) {
... | [
"public",
"boolean",
"previous",
"(",
")",
"{",
"if",
"(",
"indexes",
".",
"length",
"<=",
"1",
"||",
"permutation",
"<=",
"0",
")",
"return",
"false",
";",
"int",
"N",
"=",
"indexes",
".",
"length",
"-",
"2",
";",
"int",
"k",
"=",
"N",
";",
"whi... | This will undo a permutation. | [
"This",
"will",
"undo",
"a",
"permutation",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Permute.java#L141-L168 | train |
lessthanoptimal/ddogleg | src/org/ddogleg/combinatorics/Permute.java | Permute.getPermutation | public List<T> getPermutation(List<T> storage) {
if( storage == null )
storage = new ArrayList<T>();
else
storage.clear();
for( int i = 0; i < list.size(); i++ ) {
storage.add(get(i));
}
return storage;
} | java | public List<T> getPermutation(List<T> storage) {
if( storage == null )
storage = new ArrayList<T>();
else
storage.clear();
for( int i = 0; i < list.size(); i++ ) {
storage.add(get(i));
}
return storage;
} | [
"public",
"List",
"<",
"T",
">",
"getPermutation",
"(",
"List",
"<",
"T",
">",
"storage",
")",
"{",
"if",
"(",
"storage",
"==",
"null",
")",
"storage",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"else",
"storage",
".",
"clear",
"(",
"... | Returns a list containing the current permutation.
@param storage Optional storage. If null a new list will be declared.
@return Current permutation | [
"Returns",
"a",
"list",
"containing",
"the",
"current",
"permutation",
"."
] | 3786bf448ba23d0e04962dd08c34fa68de276029 | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/combinatorics/Permute.java#L201-L212 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.recipient | @Override
public Sms recipient(Recipient... recipients) {
this.recipients.addAll(Arrays.asList(recipients));
return this;
} | java | @Override
public Sms recipient(Recipient... recipients) {
this.recipients.addAll(Arrays.asList(recipients));
return this;
} | [
"@",
"Override",
"public",
"Sms",
"recipient",
"(",
"Recipient",
"...",
"recipients",
")",
"{",
"this",
".",
"recipients",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"recipients",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a recipient for the message
@param recipients
one or several recipient to add
@return this instance for fluent chaining | [
"Add",
"a",
"recipient",
"for",
"the",
"message"
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L169-L173 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.from | public Sms from(String name, String phoneNumber) {
return from(name, new PhoneNumber(phoneNumber));
} | java | public Sms from(String name, String phoneNumber) {
return from(name, new PhoneNumber(phoneNumber));
} | [
"public",
"Sms",
"from",
"(",
"String",
"name",
",",
"String",
"phoneNumber",
")",
"{",
"return",
"from",
"(",
"name",
",",
"new",
"PhoneNumber",
"(",
"phoneNumber",
")",
")",
";",
"}"
] | Set the sender using the phone number as string.
@param name
the name of the sender
@param phoneNumber
the sender number
@return this instance for fluent chaining | [
"Set",
"the",
"sender",
"using",
"the",
"phone",
"number",
"as",
"string",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L206-L208 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.to | public Sms to(PhoneNumber... numbers) {
for (PhoneNumber number : numbers) {
to((String) null, number);
}
return this;
} | java | public Sms to(PhoneNumber... numbers) {
for (PhoneNumber number : numbers) {
to((String) null, number);
}
return this;
} | [
"public",
"Sms",
"to",
"(",
"PhoneNumber",
"...",
"numbers",
")",
"{",
"for",
"(",
"PhoneNumber",
"number",
":",
"numbers",
")",
"{",
"to",
"(",
"(",
"String",
")",
"null",
",",
"number",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a recipient specifying the phone number.
@param numbers
one or several recipient numbers
@return this instance for fluent chaining | [
"Add",
"a",
"recipient",
"specifying",
"the",
"phone",
"number",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L230-L235 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.to | public Sms to(String... numbers) {
for (String num : numbers) {
to(new Recipient(num));
}
return this;
} | java | public Sms to(String... numbers) {
for (String num : numbers) {
to(new Recipient(num));
}
return this;
} | [
"public",
"Sms",
"to",
"(",
"String",
"...",
"numbers",
")",
"{",
"for",
"(",
"String",
"num",
":",
"numbers",
")",
"{",
"to",
"(",
"new",
"Recipient",
"(",
"num",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a recipient specifying the phone number as string.
@param numbers
one or several recipient numbers
@return this instance for fluent chaining | [
"Add",
"a",
"recipient",
"specifying",
"the",
"phone",
"number",
"as",
"string",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L244-L249 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.to | public Sms to(String name, PhoneNumber number) {
to(new Recipient(name, number));
return this;
} | java | public Sms to(String name, PhoneNumber number) {
to(new Recipient(name, number));
return this;
} | [
"public",
"Sms",
"to",
"(",
"String",
"name",
",",
"PhoneNumber",
"number",
")",
"{",
"to",
"(",
"new",
"Recipient",
"(",
"name",
",",
"number",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a recipient specifying the name and the phone number.
@param name
the name of the recipient
@param number
the number of the recipient
@return this instance for fluent chaining | [
"Add",
"a",
"recipient",
"specifying",
"the",
"name",
"and",
"the",
"phone",
"number",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L260-L263 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.toRecipient | public static Recipient[] toRecipient(PhoneNumber[] to) {
Recipient[] addresses = new Recipient[to.length];
int i = 0;
for (PhoneNumber t : to) {
addresses[i++] = new Recipient(t);
}
return addresses;
} | java | public static Recipient[] toRecipient(PhoneNumber[] to) {
Recipient[] addresses = new Recipient[to.length];
int i = 0;
for (PhoneNumber t : to) {
addresses[i++] = new Recipient(t);
}
return addresses;
} | [
"public",
"static",
"Recipient",
"[",
"]",
"toRecipient",
"(",
"PhoneNumber",
"[",
"]",
"to",
")",
"{",
"Recipient",
"[",
"]",
"addresses",
"=",
"new",
"Recipient",
"[",
"to",
".",
"length",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"PhoneNumb... | Converts a list of phone numbers to a list of recipients.
@param to
the list of phone numbers
@return the list of recipients | [
"Converts",
"a",
"list",
"of",
"phone",
"numbers",
"to",
"a",
"list",
"of",
"recipients",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L286-L293 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java | Sms.toRecipient | public static Recipient[] toRecipient(String[] to) {
Recipient[] addresses = new Recipient[to.length];
int i = 0;
for (String t : to) {
addresses[i++] = new Recipient(t);
}
return addresses;
} | java | public static Recipient[] toRecipient(String[] to) {
Recipient[] addresses = new Recipient[to.length];
int i = 0;
for (String t : to) {
addresses[i++] = new Recipient(t);
}
return addresses;
} | [
"public",
"static",
"Recipient",
"[",
"]",
"toRecipient",
"(",
"String",
"[",
"]",
"to",
")",
"{",
"Recipient",
"[",
"]",
"addresses",
"=",
"new",
"Recipient",
"[",
"to",
".",
"length",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"t"... | Converts a list of string to a list of recipients.
@param to
the list of phone numbers as string
@return the list of recipients | [
"Converts",
"a",
"list",
"of",
"string",
"to",
"a",
"list",
"of",
"recipients",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/sms/message/Sms.java#L302-L309 | train |
groupe-sii/ogham | ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/builder/sendgrid/SendGridBuilder.java | SendGridBuilder.username | public SendGridBuilder username(String... username) {
for (String u : username) {
if (u != null) {
usernames.add(u);
}
}
return this;
} | java | public SendGridBuilder username(String... username) {
for (String u : username) {
if (u != null) {
usernames.add(u);
}
}
return this;
} | [
"public",
"SendGridBuilder",
"username",
"(",
"String",
"...",
"username",
")",
"{",
"for",
"(",
"String",
"u",
":",
"username",
")",
"{",
"if",
"(",
"u",
"!=",
"null",
")",
"{",
"usernames",
".",
"add",
"(",
"u",
")",
";",
"}",
"}",
"return",
"thi... | Set username for SendGrid HTTP API.
You can specify a direct value. For example:
<pre>
.username("foo");
</pre>
<p>
You can also specify one or several property keys. For example:
<pre>
.username("${custom.property.high-priority}", "${custom.property.low-priority}");
</pre>
The properties are not immediately evalu... | [
"Set",
"username",
"for",
"SendGrid",
"HTTP",
"API",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/builder/sendgrid/SendGridBuilder.java#L212-L219 | train |
groupe-sii/ogham | ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/builder/sendgrid/SendGridBuilder.java | SendGridBuilder.password | public SendGridBuilder password(String... password) {
for (String p : password) {
if (p != null) {
passwords.add(p);
}
}
return this;
} | java | public SendGridBuilder password(String... password) {
for (String p : password) {
if (p != null) {
passwords.add(p);
}
}
return this;
} | [
"public",
"SendGridBuilder",
"password",
"(",
"String",
"...",
"password",
")",
"{",
"for",
"(",
"String",
"p",
":",
"password",
")",
"{",
"if",
"(",
"p",
"!=",
"null",
")",
"{",
"passwords",
".",
"add",
"(",
"p",
")",
";",
"}",
"}",
"return",
"thi... | Set password for SendGrid HTTP API.
You can specify a direct value. For example:
<pre>
.password("foo");
</pre>
<p>
You can also specify one or several property keys. For example:
<pre>
.password("${custom.property.high-priority}", "${custom.property.low-priority}");
</pre>
The properties are not immediately evalu... | [
"Set",
"password",
"for",
"SendGrid",
"HTTP",
"API",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/builder/sendgrid/SendGridBuilder.java#L249-L256 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/core/util/bean/BeanWrapperUtils.java | BeanWrapperUtils.isInvalid | public static boolean isInvalid(Object bean) {
if (bean == null) {
return false;
}
return isPrimitiveOrWrapper(bean.getClass())
|| INVALID_TYPES.contains(bean.getClass())
|| isInstanceOfInvalid(bean.getClass());
} | java | public static boolean isInvalid(Object bean) {
if (bean == null) {
return false;
}
return isPrimitiveOrWrapper(bean.getClass())
|| INVALID_TYPES.contains(bean.getClass())
|| isInstanceOfInvalid(bean.getClass());
} | [
"public",
"static",
"boolean",
"isInvalid",
"(",
"Object",
"bean",
")",
"{",
"if",
"(",
"bean",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isPrimitiveOrWrapper",
"(",
"bean",
".",
"getClass",
"(",
")",
")",
"||",
"INVALID_TYPES",
"."... | Check if the bean type can be wrapped or not.
@param bean
the bean instance
@return false if null or valid type, true if primitive type or string | [
"Check",
"if",
"the",
"bean",
"type",
"can",
"be",
"wrapped",
"or",
"not",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/core/util/bean/BeanWrapperUtils.java#L38-L45 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/email/message/Email.java | Email.recipient | @Override
public Email recipient(Recipient... recipients) {
this.recipients.addAll(Arrays.asList(recipients));
return this;
} | java | @Override
public Email recipient(Recipient... recipients) {
this.recipients.addAll(Arrays.asList(recipients));
return this;
} | [
"@",
"Override",
"public",
"Email",
"recipient",
"(",
"Recipient",
"...",
"recipients",
")",
"{",
"this",
".",
"recipients",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"recipients",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a recipient of the mail.
@param recipients
one or several recipient to add
@return this instance for fluent chaining | [
"Add",
"a",
"recipient",
"of",
"the",
"mail",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/email/message/Email.java#L296-L300 | train |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/email/message/Email.java | Email.to | public Email to(EmailAddress... to) {
for (EmailAddress t : to) {
recipient(t, RecipientType.TO);
}
return this;
} | java | public Email to(EmailAddress... to) {
for (EmailAddress t : to) {
recipient(t, RecipientType.TO);
}
return this;
} | [
"public",
"Email",
"to",
"(",
"EmailAddress",
"...",
"to",
")",
"{",
"for",
"(",
"EmailAddress",
"t",
":",
"to",
")",
"{",
"recipient",
"(",
"t",
",",
"RecipientType",
".",
"TO",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a "to" recipient address.
@param to
one or several recipient addresses
@return this instance for fluent chaining | [
"Add",
"a",
"to",
"recipient",
"address",
"."
] | e273b845604add74b5a25dfd931cb3c166b1008f | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/email/message/Email.java#L324-L329 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.