id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
162,300 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.parse | public static <E> E parse(InputStream is, ParameterizedType<E> jsonObjectType) throws IOException {
return mapperFor(jsonObjectType).parse(is);
} | java | public static <E> E parse(InputStream is, ParameterizedType<E> jsonObjectType) throws IOException {
return mapperFor(jsonObjectType).parse(is);
} | [
"public",
"static",
"<",
"E",
">",
"E",
"parse",
"(",
"InputStream",
"is",
",",
"ParameterizedType",
"<",
"E",
">",
"jsonObjectType",
")",
"throws",
"IOException",
"{",
"return",
"mapperFor",
"(",
"jsonObjectType",
")",
".",
"parse",
"(",
"is",
")",
";",
"}"
] | Parse a parameterized object from an InputStream.
@param is The InputStream, most likely from your networking library.
@param jsonObjectType The ParameterizedType describing the object. Ex: LoganSquare.parse(is, new ParameterizedType<MyModel<OtherModel>>() { }); | [
"Parse",
"a",
"parameterized",
"object",
"from",
"an",
"InputStream",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L88-L90 |
162,301 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.serialize | @SuppressWarnings("unchecked")
public static <E> String serialize(E object, ParameterizedType<E> parameterizedType) throws IOException {
return mapperFor(parameterizedType).serialize(object);
} | java | @SuppressWarnings("unchecked")
public static <E> String serialize(E object, ParameterizedType<E> parameterizedType) throws IOException {
return mapperFor(parameterizedType).serialize(object);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"String",
"serialize",
"(",
"E",
"object",
",",
"ParameterizedType",
"<",
"E",
">",
"parameterizedType",
")",
"throws",
"IOException",
"{",
"return",
"mapperFor",
"(",
"parameterizedType",
")",
".",
"serialize",
"(",
"object",
")",
";",
"}"
] | Serialize a parameterized object to a JSON String.
@param object The object to serialize.
@param parameterizedType The ParameterizedType describing the object. Ex: LoganSquare.serialize(object, new ParameterizedType<MyModel<OtherModel>>() { }); | [
"Serialize",
"a",
"parameterized",
"object",
"to",
"a",
"JSON",
"String",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L169-L172 |
162,302 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.serialize | @SuppressWarnings("unchecked")
public static <E> void serialize(E object, ParameterizedType<E> parameterizedType, OutputStream os) throws IOException {
mapperFor(parameterizedType).serialize(object, os);
} | java | @SuppressWarnings("unchecked")
public static <E> void serialize(E object, ParameterizedType<E> parameterizedType, OutputStream os) throws IOException {
mapperFor(parameterizedType).serialize(object, os);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"void",
"serialize",
"(",
"E",
"object",
",",
"ParameterizedType",
"<",
"E",
">",
"parameterizedType",
",",
"OutputStream",
"os",
")",
"throws",
"IOException",
"{",
"mapperFor",
"(",
"parameterizedType",
")",
".",
"serialize",
"(",
"object",
",",
"os",
")",
";",
"}"
] | Serialize a parameterized object to an OutputStream.
@param object The object to serialize.
@param parameterizedType The ParameterizedType describing the object. Ex: LoganSquare.serialize(object, new ParameterizedType<MyModel<OtherModel>>() { }, os);
@param os The OutputStream being written to. | [
"Serialize",
"a",
"parameterized",
"object",
"to",
"an",
"OutputStream",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L181-L184 |
162,303 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.serialize | public static <E> String serialize(Map<String, E> map, Class<E> jsonObjectClass) throws IOException {
return mapperFor(jsonObjectClass).serialize(map);
} | java | public static <E> String serialize(Map<String, E> map, Class<E> jsonObjectClass) throws IOException {
return mapperFor(jsonObjectClass).serialize(map);
} | [
"public",
"static",
"<",
"E",
">",
"String",
"serialize",
"(",
"Map",
"<",
"String",
",",
"E",
">",
"map",
",",
"Class",
"<",
"E",
">",
"jsonObjectClass",
")",
"throws",
"IOException",
"{",
"return",
"mapperFor",
"(",
"jsonObjectClass",
")",
".",
"serialize",
"(",
"map",
")",
";",
"}"
] | Serialize a map of objects to a JSON String.
@param map The map of objects to serialize.
@param jsonObjectClass The @JsonObject class of the list elements | [
"Serialize",
"a",
"map",
"of",
"objects",
"to",
"a",
"JSON",
"String",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L213-L215 |
162,304 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.typeConverterFor | @SuppressWarnings("unchecked")
public static <E> TypeConverter<E> typeConverterFor(Class<E> cls) throws NoSuchTypeConverterException {
TypeConverter<E> typeConverter = TYPE_CONVERTERS.get(cls);
if (typeConverter == null) {
throw new NoSuchTypeConverterException(cls);
}
return typeConverter;
} | java | @SuppressWarnings("unchecked")
public static <E> TypeConverter<E> typeConverterFor(Class<E> cls) throws NoSuchTypeConverterException {
TypeConverter<E> typeConverter = TYPE_CONVERTERS.get(cls);
if (typeConverter == null) {
throw new NoSuchTypeConverterException(cls);
}
return typeConverter;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"TypeConverter",
"<",
"E",
">",
"typeConverterFor",
"(",
"Class",
"<",
"E",
">",
"cls",
")",
"throws",
"NoSuchTypeConverterException",
"{",
"TypeConverter",
"<",
"E",
">",
"typeConverter",
"=",
"TYPE_CONVERTERS",
".",
"get",
"(",
"cls",
")",
";",
"if",
"(",
"typeConverter",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchTypeConverterException",
"(",
"cls",
")",
";",
"}",
"return",
"typeConverter",
";",
"}"
] | Returns a TypeConverter for a given class.
@param cls The class for which the TypeConverter should be fetched. | [
"Returns",
"a",
"TypeConverter",
"for",
"a",
"given",
"class",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L334-L341 |
162,305 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java | LoganSquare.registerTypeConverter | public static <E> void registerTypeConverter(Class<E> cls, TypeConverter<E> converter) {
TYPE_CONVERTERS.put(cls, converter);
} | java | public static <E> void registerTypeConverter(Class<E> cls, TypeConverter<E> converter) {
TYPE_CONVERTERS.put(cls, converter);
} | [
"public",
"static",
"<",
"E",
">",
"void",
"registerTypeConverter",
"(",
"Class",
"<",
"E",
">",
"cls",
",",
"TypeConverter",
"<",
"E",
">",
"converter",
")",
"{",
"TYPE_CONVERTERS",
".",
"put",
"(",
"cls",
",",
"converter",
")",
";",
"}"
] | Register a new TypeConverter for parsing and serialization.
@param cls The class for which the TypeConverter should be used.
@param converter The TypeConverter | [
"Register",
"a",
"new",
"TypeConverter",
"for",
"parsing",
"and",
"serialization",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/LoganSquare.java#L349-L351 |
162,306 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/util/SimpleArrayMap.java | SimpleArrayMap.indexOfKey | public int indexOfKey(Object key) {
return key == null ? indexOfNull() : indexOf(key, key.hashCode());
} | java | public int indexOfKey(Object key) {
return key == null ? indexOfNull() : indexOf(key, key.hashCode());
} | [
"public",
"int",
"indexOfKey",
"(",
"Object",
"key",
")",
"{",
"return",
"key",
"==",
"null",
"?",
"indexOfNull",
"(",
")",
":",
"indexOf",
"(",
"key",
",",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"}"
] | Returns the index of a key in the set.
@param key The key to search for.
@return Returns the index of the key if it exists, else a negative integer. | [
"Returns",
"the",
"index",
"of",
"a",
"key",
"in",
"the",
"set",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/util/SimpleArrayMap.java#L273-L275 |
162,307 | bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/util/SimpleArrayMap.java | SimpleArrayMap.put | public V put(K key, V value) {
final int hash;
int index;
if (key == null) {
hash = 0;
index = indexOfNull();
} else {
hash = key.hashCode();
index = indexOf(key, hash);
}
if (index >= 0) {
index = (index<<1) + 1;
final V old = (V)mArray[index];
mArray[index] = value;
return old;
}
index = ~index;
if (mSize >= mHashes.length) {
final int n = mSize >= (BASE_SIZE*2) ? (mSize+(mSize>>1))
: (mSize >= BASE_SIZE ? (BASE_SIZE*2) : BASE_SIZE);
final int[] ohashes = mHashes;
final Object[] oarray = mArray;
allocArrays(n);
if (mHashes.length > 0) {
System.arraycopy(ohashes, 0, mHashes, 0, ohashes.length);
System.arraycopy(oarray, 0, mArray, 0, oarray.length);
}
freeArrays(ohashes, oarray, mSize);
}
if (index < mSize) {
System.arraycopy(mHashes, index, mHashes, index + 1, mSize - index);
System.arraycopy(mArray, index << 1, mArray, (index + 1) << 1, (mSize - index) << 1);
}
mHashes[index] = hash;
mArray[index<<1] = key;
mArray[(index<<1)+1] = value;
mSize++;
return null;
} | java | public V put(K key, V value) {
final int hash;
int index;
if (key == null) {
hash = 0;
index = indexOfNull();
} else {
hash = key.hashCode();
index = indexOf(key, hash);
}
if (index >= 0) {
index = (index<<1) + 1;
final V old = (V)mArray[index];
mArray[index] = value;
return old;
}
index = ~index;
if (mSize >= mHashes.length) {
final int n = mSize >= (BASE_SIZE*2) ? (mSize+(mSize>>1))
: (mSize >= BASE_SIZE ? (BASE_SIZE*2) : BASE_SIZE);
final int[] ohashes = mHashes;
final Object[] oarray = mArray;
allocArrays(n);
if (mHashes.length > 0) {
System.arraycopy(ohashes, 0, mHashes, 0, ohashes.length);
System.arraycopy(oarray, 0, mArray, 0, oarray.length);
}
freeArrays(ohashes, oarray, mSize);
}
if (index < mSize) {
System.arraycopy(mHashes, index, mHashes, index + 1, mSize - index);
System.arraycopy(mArray, index << 1, mArray, (index + 1) << 1, (mSize - index) << 1);
}
mHashes[index] = hash;
mArray[index<<1] = key;
mArray[(index<<1)+1] = value;
mSize++;
return null;
} | [
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"final",
"int",
"hash",
";",
"int",
"index",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"hash",
"=",
"0",
";",
"index",
"=",
"indexOfNull",
"(",
")",
";",
"}",
"else",
"{",
"hash",
"=",
"key",
".",
"hashCode",
"(",
")",
";",
"index",
"=",
"indexOf",
"(",
"key",
",",
"hash",
")",
";",
"}",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"index",
"=",
"(",
"index",
"<<",
"1",
")",
"+",
"1",
";",
"final",
"V",
"old",
"=",
"(",
"V",
")",
"mArray",
"[",
"index",
"]",
";",
"mArray",
"[",
"index",
"]",
"=",
"value",
";",
"return",
"old",
";",
"}",
"index",
"=",
"~",
"index",
";",
"if",
"(",
"mSize",
">=",
"mHashes",
".",
"length",
")",
"{",
"final",
"int",
"n",
"=",
"mSize",
">=",
"(",
"BASE_SIZE",
"*",
"2",
")",
"?",
"(",
"mSize",
"+",
"(",
"mSize",
">>",
"1",
")",
")",
":",
"(",
"mSize",
">=",
"BASE_SIZE",
"?",
"(",
"BASE_SIZE",
"*",
"2",
")",
":",
"BASE_SIZE",
")",
";",
"final",
"int",
"[",
"]",
"ohashes",
"=",
"mHashes",
";",
"final",
"Object",
"[",
"]",
"oarray",
"=",
"mArray",
";",
"allocArrays",
"(",
"n",
")",
";",
"if",
"(",
"mHashes",
".",
"length",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"ohashes",
",",
"0",
",",
"mHashes",
",",
"0",
",",
"ohashes",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"oarray",
",",
"0",
",",
"mArray",
",",
"0",
",",
"oarray",
".",
"length",
")",
";",
"}",
"freeArrays",
"(",
"ohashes",
",",
"oarray",
",",
"mSize",
")",
";",
"}",
"if",
"(",
"index",
"<",
"mSize",
")",
"{",
"System",
".",
"arraycopy",
"(",
"mHashes",
",",
"index",
",",
"mHashes",
",",
"index",
"+",
"1",
",",
"mSize",
"-",
"index",
")",
";",
"System",
".",
"arraycopy",
"(",
"mArray",
",",
"index",
"<<",
"1",
",",
"mArray",
",",
"(",
"index",
"+",
"1",
")",
"<<",
"1",
",",
"(",
"mSize",
"-",
"index",
")",
"<<",
"1",
")",
";",
"}",
"mHashes",
"[",
"index",
"]",
"=",
"hash",
";",
"mArray",
"[",
"index",
"<<",
"1",
"]",
"=",
"key",
";",
"mArray",
"[",
"(",
"index",
"<<",
"1",
")",
"+",
"1",
"]",
"=",
"value",
";",
"mSize",
"++",
";",
"return",
"null",
";",
"}"
] | Add a new value to the array map.
@param key The key under which to store the value. <b>Must not be null.</b> If
this key already exists in the array, its value will be replaced.
@param value The value to store for the given key.
@return Returns the old value that was stored for the given key, or null if there
was no such key. | [
"Add",
"a",
"new",
"value",
"to",
"the",
"array",
"map",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/util/SimpleArrayMap.java#L364-L408 |
162,308 | edvin/fxlauncher | src/main/java/fxlauncher/LauncherParams.java | LauncherParams.computeUnnamedParams | private void computeUnnamedParams() {
unnamedParams.addAll(rawArgs.stream().filter(arg -> !isNamedParam(arg)).collect(Collectors.toList()));
} | java | private void computeUnnamedParams() {
unnamedParams.addAll(rawArgs.stream().filter(arg -> !isNamedParam(arg)).collect(Collectors.toList()));
} | [
"private",
"void",
"computeUnnamedParams",
"(",
")",
"{",
"unnamedParams",
".",
"addAll",
"(",
"rawArgs",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"arg",
"->",
"!",
"isNamedParam",
"(",
"arg",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"}"
] | This method computes the list of unnamed parameters, by filtering the
list of raw arguments, stripping out the named parameters. | [
"This",
"method",
"computes",
"the",
"list",
"of",
"unnamed",
"parameters",
"by",
"filtering",
"the",
"list",
"of",
"raw",
"arguments",
"stripping",
"out",
"the",
"named",
"parameters",
"."
] | 3024b413c8743d1e3576e91f9911b68076bcb625 | https://github.com/edvin/fxlauncher/blob/3024b413c8743d1e3576e91f9911b68076bcb625/src/main/java/fxlauncher/LauncherParams.java#L97-L99 |
162,309 | lessthanoptimal/ejml | examples/src/org/ejml/example/StatisticsMatrix.java | StatisticsMatrix.wrap | public static StatisticsMatrix wrap( DMatrixRMaj m ) {
StatisticsMatrix ret = new StatisticsMatrix();
ret.setMatrix( m );
return ret;
} | java | public static StatisticsMatrix wrap( DMatrixRMaj m ) {
StatisticsMatrix ret = new StatisticsMatrix();
ret.setMatrix( m );
return ret;
} | [
"public",
"static",
"StatisticsMatrix",
"wrap",
"(",
"DMatrixRMaj",
"m",
")",
"{",
"StatisticsMatrix",
"ret",
"=",
"new",
"StatisticsMatrix",
"(",
")",
";",
"ret",
".",
"setMatrix",
"(",
"m",
")",
";",
"return",
"ret",
";",
"}"
] | Wraps a StatisticsMatrix around 'm'. Does NOT create a copy of 'm' but saves a reference
to it. | [
"Wraps",
"a",
"StatisticsMatrix",
"around",
"m",
".",
"Does",
"NOT",
"create",
"a",
"copy",
"of",
"m",
"but",
"saves",
"a",
"reference",
"to",
"it",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/StatisticsMatrix.java#L50-L55 |
162,310 | lessthanoptimal/ejml | examples/src/org/ejml/example/StatisticsMatrix.java | StatisticsMatrix.mean | public double mean() {
double total = 0;
final int N = getNumElements();
for( int i = 0; i < N; i++ ) {
total += get(i);
}
return total/N;
} | java | public double mean() {
double total = 0;
final int N = getNumElements();
for( int i = 0; i < N; i++ ) {
total += get(i);
}
return total/N;
} | [
"public",
"double",
"mean",
"(",
")",
"{",
"double",
"total",
"=",
"0",
";",
"final",
"int",
"N",
"=",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"total",
"+=",
"get",
"(",
"i",
")",
";",
"}",
"return",
"total",
"/",
"N",
";",
"}"
] | Computes the mean or average of all the elements.
@return mean | [
"Computes",
"the",
"mean",
"or",
"average",
"of",
"all",
"the",
"elements",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/StatisticsMatrix.java#L62-L71 |
162,311 | lessthanoptimal/ejml | examples/src/org/ejml/example/StatisticsMatrix.java | StatisticsMatrix.stdev | public double stdev() {
double m = mean();
double total = 0;
final int N = getNumElements();
if( N <= 1 )
throw new IllegalArgumentException("There must be more than one element to compute stdev");
for( int i = 0; i < N; i++ ) {
double x = get(i);
total += (x - m)*(x - m);
}
total /= (N-1);
return Math.sqrt(total);
} | java | public double stdev() {
double m = mean();
double total = 0;
final int N = getNumElements();
if( N <= 1 )
throw new IllegalArgumentException("There must be more than one element to compute stdev");
for( int i = 0; i < N; i++ ) {
double x = get(i);
total += (x - m)*(x - m);
}
total /= (N-1);
return Math.sqrt(total);
} | [
"public",
"double",
"stdev",
"(",
")",
"{",
"double",
"m",
"=",
"mean",
"(",
")",
";",
"double",
"total",
"=",
"0",
";",
"final",
"int",
"N",
"=",
"getNumElements",
"(",
")",
";",
"if",
"(",
"N",
"<=",
"1",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"There must be more than one element to compute stdev\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"double",
"x",
"=",
"get",
"(",
"i",
")",
";",
"total",
"+=",
"(",
"x",
"-",
"m",
")",
"*",
"(",
"x",
"-",
"m",
")",
";",
"}",
"total",
"/=",
"(",
"N",
"-",
"1",
")",
";",
"return",
"Math",
".",
"sqrt",
"(",
"total",
")",
";",
"}"
] | Computes the unbiased standard deviation of all the elements.
@return standard deviation | [
"Computes",
"the",
"unbiased",
"standard",
"deviation",
"of",
"all",
"the",
"elements",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/StatisticsMatrix.java#L78-L97 |
162,312 | lessthanoptimal/ejml | examples/src/org/ejml/example/StatisticsMatrix.java | StatisticsMatrix.createMatrix | @Override
protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
return new StatisticsMatrix(numRows,numCols);
} | java | @Override
protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
return new StatisticsMatrix(numRows,numCols);
} | [
"@",
"Override",
"protected",
"StatisticsMatrix",
"createMatrix",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"MatrixType",
"type",
")",
"{",
"return",
"new",
"StatisticsMatrix",
"(",
"numRows",
",",
"numCols",
")",
";",
"}"
] | Returns a matrix of StatisticsMatrix type so that SimpleMatrix functions create matrices
of the correct type. | [
"Returns",
"a",
"matrix",
"of",
"StatisticsMatrix",
"type",
"so",
"that",
"SimpleMatrix",
"functions",
"create",
"matrices",
"of",
"the",
"correct",
"type",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/StatisticsMatrix.java#L103-L106 |
162,313 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/chol/CholeskyOuterForm_DDRB.java | CholeskyOuterForm_DDRB.decompose | @Override
public boolean decompose(DMatrixRBlock A) {
if( A.numCols != A.numRows )
throw new IllegalArgumentException("A must be square");
this.T = A;
if( lower )
return decomposeLower();
else
return decomposeUpper();
} | java | @Override
public boolean decompose(DMatrixRBlock A) {
if( A.numCols != A.numRows )
throw new IllegalArgumentException("A must be square");
this.T = A;
if( lower )
return decomposeLower();
else
return decomposeUpper();
} | [
"@",
"Override",
"public",
"boolean",
"decompose",
"(",
"DMatrixRBlock",
"A",
")",
"{",
"if",
"(",
"A",
".",
"numCols",
"!=",
"A",
".",
"numRows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A must be square\"",
")",
";",
"this",
".",
"T",
"=",
"A",
";",
"if",
"(",
"lower",
")",
"return",
"decomposeLower",
"(",
")",
";",
"else",
"return",
"decomposeUpper",
"(",
")",
";",
"}"
] | Decomposes the provided matrix and stores the result in the same matrix.
@param A Matrix that is to be decomposed. Modified.
@return If it succeeded or not. | [
"Decomposes",
"the",
"provided",
"matrix",
"and",
"stores",
"the",
"result",
"in",
"the",
"same",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/chol/CholeskyOuterForm_DDRB.java#L71-L82 |
162,314 | lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/MatrixIO.java | MatrixIO.saveBin | public static void saveBin(DMatrix A, String fileName)
throws IOException
{
FileOutputStream fileStream = new FileOutputStream(fileName);
ObjectOutputStream stream = new ObjectOutputStream(fileStream);
try {
stream.writeObject(A);
stream.flush();
} finally {
// clean up
try {
stream.close();
} finally {
fileStream.close();
}
}
} | java | public static void saveBin(DMatrix A, String fileName)
throws IOException
{
FileOutputStream fileStream = new FileOutputStream(fileName);
ObjectOutputStream stream = new ObjectOutputStream(fileStream);
try {
stream.writeObject(A);
stream.flush();
} finally {
// clean up
try {
stream.close();
} finally {
fileStream.close();
}
}
} | [
"public",
"static",
"void",
"saveBin",
"(",
"DMatrix",
"A",
",",
"String",
"fileName",
")",
"throws",
"IOException",
"{",
"FileOutputStream",
"fileStream",
"=",
"new",
"FileOutputStream",
"(",
"fileName",
")",
";",
"ObjectOutputStream",
"stream",
"=",
"new",
"ObjectOutputStream",
"(",
"fileStream",
")",
";",
"try",
"{",
"stream",
".",
"writeObject",
"(",
"A",
")",
";",
"stream",
".",
"flush",
"(",
")",
";",
"}",
"finally",
"{",
"// clean up",
"try",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"finally",
"{",
"fileStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Saves a matrix to disk using Java binary serialization.
@param A The matrix being saved.
@param fileName Name of the file its being saved at.
@throws java.io.IOException | [
"Saves",
"a",
"matrix",
"to",
"disk",
"using",
"Java",
"binary",
"serialization",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/MatrixIO.java#L48-L66 |
162,315 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java | RandomMatrices_DSCC.rectangle | public static DMatrixSparseCSC rectangle(int numRows , int numCols , int nz_total ,
double min , double max , Random rand ) {
nz_total = Math.min(numCols*numRows,nz_total);
int[] selected = UtilEjml.shuffled(numRows*numCols, nz_total, rand);
Arrays.sort(selected,0,nz_total);
DMatrixSparseCSC ret = new DMatrixSparseCSC(numRows,numCols,nz_total);
ret.indicesSorted = true;
// compute the number of elements in each column
int hist[] = new int[ numCols ];
for (int i = 0; i < nz_total; i++) {
hist[selected[i]/numRows]++;
}
// define col_idx
ret.histogramToStructure(hist);
for (int i = 0; i < nz_total; i++) {
int row = selected[i]%numRows;
ret.nz_rows[i] = row;
ret.nz_values[i] = rand.nextDouble()*(max-min)+min;
}
return ret;
} | java | public static DMatrixSparseCSC rectangle(int numRows , int numCols , int nz_total ,
double min , double max , Random rand ) {
nz_total = Math.min(numCols*numRows,nz_total);
int[] selected = UtilEjml.shuffled(numRows*numCols, nz_total, rand);
Arrays.sort(selected,0,nz_total);
DMatrixSparseCSC ret = new DMatrixSparseCSC(numRows,numCols,nz_total);
ret.indicesSorted = true;
// compute the number of elements in each column
int hist[] = new int[ numCols ];
for (int i = 0; i < nz_total; i++) {
hist[selected[i]/numRows]++;
}
// define col_idx
ret.histogramToStructure(hist);
for (int i = 0; i < nz_total; i++) {
int row = selected[i]%numRows;
ret.nz_rows[i] = row;
ret.nz_values[i] = rand.nextDouble()*(max-min)+min;
}
return ret;
} | [
"public",
"static",
"DMatrixSparseCSC",
"rectangle",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"int",
"nz_total",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"nz_total",
"=",
"Math",
".",
"min",
"(",
"numCols",
"*",
"numRows",
",",
"nz_total",
")",
";",
"int",
"[",
"]",
"selected",
"=",
"UtilEjml",
".",
"shuffled",
"(",
"numRows",
"*",
"numCols",
",",
"nz_total",
",",
"rand",
")",
";",
"Arrays",
".",
"sort",
"(",
"selected",
",",
"0",
",",
"nz_total",
")",
";",
"DMatrixSparseCSC",
"ret",
"=",
"new",
"DMatrixSparseCSC",
"(",
"numRows",
",",
"numCols",
",",
"nz_total",
")",
";",
"ret",
".",
"indicesSorted",
"=",
"true",
";",
"// compute the number of elements in each column",
"int",
"hist",
"[",
"]",
"=",
"new",
"int",
"[",
"numCols",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nz_total",
";",
"i",
"++",
")",
"{",
"hist",
"[",
"selected",
"[",
"i",
"]",
"/",
"numRows",
"]",
"++",
";",
"}",
"// define col_idx",
"ret",
".",
"histogramToStructure",
"(",
"hist",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nz_total",
";",
"i",
"++",
")",
"{",
"int",
"row",
"=",
"selected",
"[",
"i",
"]",
"%",
"numRows",
";",
"ret",
".",
"nz_rows",
"[",
"i",
"]",
"=",
"row",
";",
"ret",
".",
"nz_values",
"[",
"i",
"]",
"=",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"(",
"max",
"-",
"min",
")",
"+",
"min",
";",
"}",
"return",
"ret",
";",
"}"
] | Randomly generates matrix with the specified number of non-zero elements filled with values from min to max.
@param numRows Number of rows
@param numCols Number of columns
@param nz_total Total number of non-zero elements in the matrix
@param min Minimum element value, inclusive
@param max Maximum element value, inclusive
@param rand Random number generator
@return Randomly generated matrix | [
"Randomly",
"generates",
"matrix",
"with",
"the",
"specified",
"number",
"of",
"non",
"-",
"zero",
"elements",
"filled",
"with",
"values",
"from",
"min",
"to",
"max",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java#L46-L73 |
162,316 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java | RandomMatrices_DSCC.symmetric | public static DMatrixSparseCSC symmetric( int N , int nz_total ,
double min , double max , Random rand) {
// compute the number of elements in the triangle, including diagonal
int Ntriagle = (N*N+N)/2;
// create a list of open elements
int open[] = new int[Ntriagle];
for (int row = 0, index = 0; row < N; row++) {
for (int col = row; col < N; col++, index++) {
open[index] = row*N+col;
}
}
// perform a random draw
UtilEjml.shuffle(open,open.length,0,nz_total,rand);
Arrays.sort(open,0,nz_total);
// construct the matrix
DMatrixSparseTriplet A = new DMatrixSparseTriplet(N,N,nz_total*2);
for (int i = 0; i < nz_total; i++) {
int index = open[i];
int row = index/N;
int col = index%N;
double value = rand.nextDouble()*(max-min)+min;
if( row == col ) {
A.addItem(row,col,value);
} else {
A.addItem(row,col,value);
A.addItem(col,row,value);
}
}
DMatrixSparseCSC B = new DMatrixSparseCSC(N,N,A.nz_length);
ConvertDMatrixStruct.convert(A,B);
return B;
} | java | public static DMatrixSparseCSC symmetric( int N , int nz_total ,
double min , double max , Random rand) {
// compute the number of elements in the triangle, including diagonal
int Ntriagle = (N*N+N)/2;
// create a list of open elements
int open[] = new int[Ntriagle];
for (int row = 0, index = 0; row < N; row++) {
for (int col = row; col < N; col++, index++) {
open[index] = row*N+col;
}
}
// perform a random draw
UtilEjml.shuffle(open,open.length,0,nz_total,rand);
Arrays.sort(open,0,nz_total);
// construct the matrix
DMatrixSparseTriplet A = new DMatrixSparseTriplet(N,N,nz_total*2);
for (int i = 0; i < nz_total; i++) {
int index = open[i];
int row = index/N;
int col = index%N;
double value = rand.nextDouble()*(max-min)+min;
if( row == col ) {
A.addItem(row,col,value);
} else {
A.addItem(row,col,value);
A.addItem(col,row,value);
}
}
DMatrixSparseCSC B = new DMatrixSparseCSC(N,N,A.nz_length);
ConvertDMatrixStruct.convert(A,B);
return B;
} | [
"public",
"static",
"DMatrixSparseCSC",
"symmetric",
"(",
"int",
"N",
",",
"int",
"nz_total",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"// compute the number of elements in the triangle, including diagonal",
"int",
"Ntriagle",
"=",
"(",
"N",
"*",
"N",
"+",
"N",
")",
"/",
"2",
";",
"// create a list of open elements",
"int",
"open",
"[",
"]",
"=",
"new",
"int",
"[",
"Ntriagle",
"]",
";",
"for",
"(",
"int",
"row",
"=",
"0",
",",
"index",
"=",
"0",
";",
"row",
"<",
"N",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"col",
"=",
"row",
";",
"col",
"<",
"N",
";",
"col",
"++",
",",
"index",
"++",
")",
"{",
"open",
"[",
"index",
"]",
"=",
"row",
"*",
"N",
"+",
"col",
";",
"}",
"}",
"// perform a random draw",
"UtilEjml",
".",
"shuffle",
"(",
"open",
",",
"open",
".",
"length",
",",
"0",
",",
"nz_total",
",",
"rand",
")",
";",
"Arrays",
".",
"sort",
"(",
"open",
",",
"0",
",",
"nz_total",
")",
";",
"// construct the matrix",
"DMatrixSparseTriplet",
"A",
"=",
"new",
"DMatrixSparseTriplet",
"(",
"N",
",",
"N",
",",
"nz_total",
"*",
"2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nz_total",
";",
"i",
"++",
")",
"{",
"int",
"index",
"=",
"open",
"[",
"i",
"]",
";",
"int",
"row",
"=",
"index",
"/",
"N",
";",
"int",
"col",
"=",
"index",
"%",
"N",
";",
"double",
"value",
"=",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"(",
"max",
"-",
"min",
")",
"+",
"min",
";",
"if",
"(",
"row",
"==",
"col",
")",
"{",
"A",
".",
"addItem",
"(",
"row",
",",
"col",
",",
"value",
")",
";",
"}",
"else",
"{",
"A",
".",
"addItem",
"(",
"row",
",",
"col",
",",
"value",
")",
";",
"A",
".",
"addItem",
"(",
"col",
",",
"row",
",",
"value",
")",
";",
"}",
"}",
"DMatrixSparseCSC",
"B",
"=",
"new",
"DMatrixSparseCSC",
"(",
"N",
",",
"N",
",",
"A",
".",
"nz_length",
")",
";",
"ConvertDMatrixStruct",
".",
"convert",
"(",
"A",
",",
"B",
")",
";",
"return",
"B",
";",
"}"
] | Creates a random symmetric matrix. The entire matrix will be filled in, not just a triangular
portion.
@param N Number of rows and columns
@param nz_total Number of nonzero elements in the triangular portion of the matrix
@param min Minimum element value, inclusive
@param max Maximum element value, inclusive
@param rand Random number generator
@return Randomly generated matrix | [
"Creates",
"a",
"random",
"symmetric",
"matrix",
".",
"The",
"entire",
"matrix",
"will",
"be",
"filled",
"in",
"not",
"just",
"a",
"triangular",
"portion",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java#L91-L129 |
162,317 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java | RandomMatrices_DSCC.triangle | public static DMatrixSparseCSC triangle( boolean upper , int N , double minFill , double maxFill , Random rand ) {
int nz = (int)(((N-1)*(N-1)/2)*(rand.nextDouble()*(maxFill-minFill)+minFill))+N;
if( upper ) {
return triangleUpper(N,0,nz,-1,1,rand);
} else {
return triangleLower(N,0,nz,-1,1,rand);
}
} | java | public static DMatrixSparseCSC triangle( boolean upper , int N , double minFill , double maxFill , Random rand ) {
int nz = (int)(((N-1)*(N-1)/2)*(rand.nextDouble()*(maxFill-minFill)+minFill))+N;
if( upper ) {
return triangleUpper(N,0,nz,-1,1,rand);
} else {
return triangleLower(N,0,nz,-1,1,rand);
}
} | [
"public",
"static",
"DMatrixSparseCSC",
"triangle",
"(",
"boolean",
"upper",
",",
"int",
"N",
",",
"double",
"minFill",
",",
"double",
"maxFill",
",",
"Random",
"rand",
")",
"{",
"int",
"nz",
"=",
"(",
"int",
")",
"(",
"(",
"(",
"N",
"-",
"1",
")",
"*",
"(",
"N",
"-",
"1",
")",
"/",
"2",
")",
"*",
"(",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"(",
"maxFill",
"-",
"minFill",
")",
"+",
"minFill",
")",
")",
"+",
"N",
";",
"if",
"(",
"upper",
")",
"{",
"return",
"triangleUpper",
"(",
"N",
",",
"0",
",",
"nz",
",",
"-",
"1",
",",
"1",
",",
"rand",
")",
";",
"}",
"else",
"{",
"return",
"triangleLower",
"(",
"N",
",",
"0",
",",
"nz",
",",
"-",
"1",
",",
"1",
",",
"rand",
")",
";",
"}",
"}"
] | Creates a triangular matrix where the amount of fill is randomly selected too.
@param upper true for upper triangular and false for lower
@param N number of rows and columns
er * @param minFill minimum fill fraction
@param maxFill maximum fill fraction
@param rand random number generator
@return Random matrix | [
"Creates",
"a",
"triangular",
"matrix",
"where",
"the",
"amount",
"of",
"fill",
"is",
"randomly",
"selected",
"too",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java#L236-L244 |
162,318 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java | RandomMatrices_DSCC.ensureNotSingular | public static void ensureNotSingular( DMatrixSparseCSC A , Random rand ) {
// if( A.numRows < A.numCols ) {
// throw new IllegalArgumentException("Fewer equations than variables");
// }
int []s = UtilEjml.shuffled(A.numRows,rand);
Arrays.sort(s);
int N = Math.min(A.numCols,A.numRows);
for (int col = 0; col < N; col++) {
A.set(s[col],col,rand.nextDouble()+0.5);
}
} | java | public static void ensureNotSingular( DMatrixSparseCSC A , Random rand ) {
// if( A.numRows < A.numCols ) {
// throw new IllegalArgumentException("Fewer equations than variables");
// }
int []s = UtilEjml.shuffled(A.numRows,rand);
Arrays.sort(s);
int N = Math.min(A.numCols,A.numRows);
for (int col = 0; col < N; col++) {
A.set(s[col],col,rand.nextDouble()+0.5);
}
} | [
"public",
"static",
"void",
"ensureNotSingular",
"(",
"DMatrixSparseCSC",
"A",
",",
"Random",
"rand",
")",
"{",
"// if( A.numRows < A.numCols ) {",
"// throw new IllegalArgumentException(\"Fewer equations than variables\");",
"// }",
"int",
"[",
"]",
"s",
"=",
"UtilEjml",
".",
"shuffled",
"(",
"A",
".",
"numRows",
",",
"rand",
")",
";",
"Arrays",
".",
"sort",
"(",
"s",
")",
";",
"int",
"N",
"=",
"Math",
".",
"min",
"(",
"A",
".",
"numCols",
",",
"A",
".",
"numRows",
")",
";",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"N",
";",
"col",
"++",
")",
"{",
"A",
".",
"set",
"(",
"s",
"[",
"col",
"]",
",",
"col",
",",
"rand",
".",
"nextDouble",
"(",
")",
"+",
"0.5",
")",
";",
"}",
"}"
] | Modies the matrix to make sure that at least one element in each column has a value | [
"Modies",
"the",
"matrix",
"to",
"make",
"sure",
"that",
"at",
"least",
"one",
"element",
"in",
"each",
"column",
"has",
"a",
"value"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/RandomMatrices_DSCC.java#L271-L283 |
162,319 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/misc/DeterminantFromMinor_DDRM.java | DeterminantFromMinor_DDRM.compute | public double compute( DMatrix1Row mat ) {
if( width != mat.numCols || width != mat.numRows ) {
throw new RuntimeException("Unexpected matrix dimension");
}
// make sure everything is in the proper state before it starts
initStructures();
// System.arraycopy(mat.data,0,minorMatrix[0],0,mat.data.length);
int level = 0;
while( true ) {
int levelWidth = width-level;
int levelIndex = levelIndexes[level];
if( levelIndex == levelWidth ) {
if( level == 0 ) {
return levelResults[0];
}
int prevLevelIndex = levelIndexes[level-1]++;
double val = mat.get((level-1)*width+levelRemoved[level-1]);
if( prevLevelIndex % 2 == 0 ) {
levelResults[level-1] += val * levelResults[level];
} else {
levelResults[level-1] -= val * levelResults[level];
}
putIntoOpen(level-1);
levelResults[level] = 0;
levelIndexes[level] = 0;
level--;
} else {
int excluded = openRemove( levelIndex );
levelRemoved[level] = excluded;
if( levelWidth == minWidth ) {
createMinor(mat);
double subresult = mat.get(level*width+levelRemoved[level]);
subresult *= UnrolledDeterminantFromMinor_DDRM.det(tempMat);
if( levelIndex % 2 == 0 ) {
levelResults[level] += subresult;
} else {
levelResults[level] -= subresult;
}
// put it back into the list
putIntoOpen(level);
levelIndexes[level]++;
} else {
level++;
}
}
}
} | java | public double compute( DMatrix1Row mat ) {
if( width != mat.numCols || width != mat.numRows ) {
throw new RuntimeException("Unexpected matrix dimension");
}
// make sure everything is in the proper state before it starts
initStructures();
// System.arraycopy(mat.data,0,minorMatrix[0],0,mat.data.length);
int level = 0;
while( true ) {
int levelWidth = width-level;
int levelIndex = levelIndexes[level];
if( levelIndex == levelWidth ) {
if( level == 0 ) {
return levelResults[0];
}
int prevLevelIndex = levelIndexes[level-1]++;
double val = mat.get((level-1)*width+levelRemoved[level-1]);
if( prevLevelIndex % 2 == 0 ) {
levelResults[level-1] += val * levelResults[level];
} else {
levelResults[level-1] -= val * levelResults[level];
}
putIntoOpen(level-1);
levelResults[level] = 0;
levelIndexes[level] = 0;
level--;
} else {
int excluded = openRemove( levelIndex );
levelRemoved[level] = excluded;
if( levelWidth == minWidth ) {
createMinor(mat);
double subresult = mat.get(level*width+levelRemoved[level]);
subresult *= UnrolledDeterminantFromMinor_DDRM.det(tempMat);
if( levelIndex % 2 == 0 ) {
levelResults[level] += subresult;
} else {
levelResults[level] -= subresult;
}
// put it back into the list
putIntoOpen(level);
levelIndexes[level]++;
} else {
level++;
}
}
}
} | [
"public",
"double",
"compute",
"(",
"DMatrix1Row",
"mat",
")",
"{",
"if",
"(",
"width",
"!=",
"mat",
".",
"numCols",
"||",
"width",
"!=",
"mat",
".",
"numRows",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected matrix dimension\"",
")",
";",
"}",
"// make sure everything is in the proper state before it starts",
"initStructures",
"(",
")",
";",
"// System.arraycopy(mat.data,0,minorMatrix[0],0,mat.data.length);",
"int",
"level",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"int",
"levelWidth",
"=",
"width",
"-",
"level",
";",
"int",
"levelIndex",
"=",
"levelIndexes",
"[",
"level",
"]",
";",
"if",
"(",
"levelIndex",
"==",
"levelWidth",
")",
"{",
"if",
"(",
"level",
"==",
"0",
")",
"{",
"return",
"levelResults",
"[",
"0",
"]",
";",
"}",
"int",
"prevLevelIndex",
"=",
"levelIndexes",
"[",
"level",
"-",
"1",
"]",
"++",
";",
"double",
"val",
"=",
"mat",
".",
"get",
"(",
"(",
"level",
"-",
"1",
")",
"*",
"width",
"+",
"levelRemoved",
"[",
"level",
"-",
"1",
"]",
")",
";",
"if",
"(",
"prevLevelIndex",
"%",
"2",
"==",
"0",
")",
"{",
"levelResults",
"[",
"level",
"-",
"1",
"]",
"+=",
"val",
"*",
"levelResults",
"[",
"level",
"]",
";",
"}",
"else",
"{",
"levelResults",
"[",
"level",
"-",
"1",
"]",
"-=",
"val",
"*",
"levelResults",
"[",
"level",
"]",
";",
"}",
"putIntoOpen",
"(",
"level",
"-",
"1",
")",
";",
"levelResults",
"[",
"level",
"]",
"=",
"0",
";",
"levelIndexes",
"[",
"level",
"]",
"=",
"0",
";",
"level",
"--",
";",
"}",
"else",
"{",
"int",
"excluded",
"=",
"openRemove",
"(",
"levelIndex",
")",
";",
"levelRemoved",
"[",
"level",
"]",
"=",
"excluded",
";",
"if",
"(",
"levelWidth",
"==",
"minWidth",
")",
"{",
"createMinor",
"(",
"mat",
")",
";",
"double",
"subresult",
"=",
"mat",
".",
"get",
"(",
"level",
"*",
"width",
"+",
"levelRemoved",
"[",
"level",
"]",
")",
";",
"subresult",
"*=",
"UnrolledDeterminantFromMinor_DDRM",
".",
"det",
"(",
"tempMat",
")",
";",
"if",
"(",
"levelIndex",
"%",
"2",
"==",
"0",
")",
"{",
"levelResults",
"[",
"level",
"]",
"+=",
"subresult",
";",
"}",
"else",
"{",
"levelResults",
"[",
"level",
"]",
"-=",
"subresult",
";",
"}",
"// put it back into the list",
"putIntoOpen",
"(",
"level",
")",
";",
"levelIndexes",
"[",
"level",
"]",
"++",
";",
"}",
"else",
"{",
"level",
"++",
";",
"}",
"}",
"}",
"}"
] | Computes the determinant for the specified matrix. It must be square and have
the same width and height as what was specified in the constructor.
@param mat The matrix whose determinant is to be computed.
@return The determinant. | [
"Computes",
"the",
"determinant",
"for",
"the",
"specified",
"matrix",
".",
"It",
"must",
"be",
"square",
"and",
"have",
"the",
"same",
"width",
"and",
"height",
"as",
"what",
"was",
"specified",
"in",
"the",
"constructor",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/misc/DeterminantFromMinor_DDRM.java#L113-L171 |
162,320 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.singularValues | public static double[] singularValues( DMatrixRMaj A ) {
SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(A.numRows,A.numCols,false,true,true);
if( svd.inputModified() ) {
A = A.copy();
}
if( !svd.decompose(A)) {
throw new RuntimeException("SVD Failed!");
}
double sv[] = svd.getSingularValues();
Arrays.sort(sv,0,svd.numberOfSingularValues());
// change the ordering to ascending
for (int i = 0; i < sv.length/2; i++) {
double tmp = sv[i];
sv[i] = sv[sv.length-i-1];
sv[sv.length-i-1] = tmp;
}
return sv;
} | java | public static double[] singularValues( DMatrixRMaj A ) {
SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(A.numRows,A.numCols,false,true,true);
if( svd.inputModified() ) {
A = A.copy();
}
if( !svd.decompose(A)) {
throw new RuntimeException("SVD Failed!");
}
double sv[] = svd.getSingularValues();
Arrays.sort(sv,0,svd.numberOfSingularValues());
// change the ordering to ascending
for (int i = 0; i < sv.length/2; i++) {
double tmp = sv[i];
sv[i] = sv[sv.length-i-1];
sv[sv.length-i-1] = tmp;
}
return sv;
} | [
"public",
"static",
"double",
"[",
"]",
"singularValues",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"SingularValueDecomposition_F64",
"<",
"DMatrixRMaj",
">",
"svd",
"=",
"DecompositionFactory_DDRM",
".",
"svd",
"(",
"A",
".",
"numRows",
",",
"A",
".",
"numCols",
",",
"false",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"svd",
".",
"inputModified",
"(",
")",
")",
"{",
"A",
"=",
"A",
".",
"copy",
"(",
")",
";",
"}",
"if",
"(",
"!",
"svd",
".",
"decompose",
"(",
"A",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"SVD Failed!\"",
")",
";",
"}",
"double",
"sv",
"[",
"]",
"=",
"svd",
".",
"getSingularValues",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"sv",
",",
"0",
",",
"svd",
".",
"numberOfSingularValues",
"(",
")",
")",
";",
"// change the ordering to ascending",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sv",
".",
"length",
"/",
"2",
";",
"i",
"++",
")",
"{",
"double",
"tmp",
"=",
"sv",
"[",
"i",
"]",
";",
"sv",
"[",
"i",
"]",
"=",
"sv",
"[",
"sv",
".",
"length",
"-",
"i",
"-",
"1",
"]",
";",
"sv",
"[",
"sv",
".",
"length",
"-",
"i",
"-",
"1",
"]",
"=",
"tmp",
";",
"}",
"return",
"sv",
";",
"}"
] | Returns an array of all the singular values in A sorted in ascending order
@param A Matrix. Not modified.
@return singular values | [
"Returns",
"an",
"array",
"of",
"all",
"the",
"singular",
"values",
"in",
"A",
"sorted",
"in",
"ascending",
"order"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L48-L69 |
162,321 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.ratioSmallestOverLargest | public static double ratioSmallestOverLargest( double []sv ) {
if( sv.length == 0 )
return Double.NaN;
double min = sv[0];
double max = min;
for (int i = 1; i < sv.length; i++) {
double v = sv[i];
if( v > max )
max = v;
else if( v < min )
min = v;
}
return min/max;
} | java | public static double ratioSmallestOverLargest( double []sv ) {
if( sv.length == 0 )
return Double.NaN;
double min = sv[0];
double max = min;
for (int i = 1; i < sv.length; i++) {
double v = sv[i];
if( v > max )
max = v;
else if( v < min )
min = v;
}
return min/max;
} | [
"public",
"static",
"double",
"ratioSmallestOverLargest",
"(",
"double",
"[",
"]",
"sv",
")",
"{",
"if",
"(",
"sv",
".",
"length",
"==",
"0",
")",
"return",
"Double",
".",
"NaN",
";",
"double",
"min",
"=",
"sv",
"[",
"0",
"]",
";",
"double",
"max",
"=",
"min",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"sv",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"v",
"=",
"sv",
"[",
"i",
"]",
";",
"if",
"(",
"v",
">",
"max",
")",
"max",
"=",
"v",
";",
"else",
"if",
"(",
"v",
"<",
"min",
")",
"min",
"=",
"v",
";",
"}",
"return",
"min",
"/",
"max",
";",
"}"
] | Computes the ratio of the smallest value to the largest. Does not assume
the array is sorted first
@param sv array
@return smallest / largest | [
"Computes",
"the",
"ratio",
"of",
"the",
"smallest",
"value",
"to",
"the",
"largest",
".",
"Does",
"not",
"assume",
"the",
"array",
"is",
"sorted",
"first"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L77-L93 |
162,322 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.rank | public static int rank( DMatrixRMaj A ) {
SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(A.numRows,A.numCols,false,true,true);
if( svd.inputModified() ) {
A = A.copy();
}
if( !svd.decompose(A)) {
throw new RuntimeException("SVD Failed!");
}
int N = svd.numberOfSingularValues();
double sv[] = svd.getSingularValues();
double threshold = singularThreshold(sv,N);
int count = 0;
for (int i = 0; i < sv.length; i++) {
if( sv[i] >= threshold ) {
count++;
}
}
return count;
} | java | public static int rank( DMatrixRMaj A ) {
SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(A.numRows,A.numCols,false,true,true);
if( svd.inputModified() ) {
A = A.copy();
}
if( !svd.decompose(A)) {
throw new RuntimeException("SVD Failed!");
}
int N = svd.numberOfSingularValues();
double sv[] = svd.getSingularValues();
double threshold = singularThreshold(sv,N);
int count = 0;
for (int i = 0; i < sv.length; i++) {
if( sv[i] >= threshold ) {
count++;
}
}
return count;
} | [
"public",
"static",
"int",
"rank",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"SingularValueDecomposition_F64",
"<",
"DMatrixRMaj",
">",
"svd",
"=",
"DecompositionFactory_DDRM",
".",
"svd",
"(",
"A",
".",
"numRows",
",",
"A",
".",
"numCols",
",",
"false",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"svd",
".",
"inputModified",
"(",
")",
")",
"{",
"A",
"=",
"A",
".",
"copy",
"(",
")",
";",
"}",
"if",
"(",
"!",
"svd",
".",
"decompose",
"(",
"A",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"SVD Failed!\"",
")",
";",
"}",
"int",
"N",
"=",
"svd",
".",
"numberOfSingularValues",
"(",
")",
";",
"double",
"sv",
"[",
"]",
"=",
"svd",
".",
"getSingularValues",
"(",
")",
";",
"double",
"threshold",
"=",
"singularThreshold",
"(",
"sv",
",",
"N",
")",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sv",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sv",
"[",
"i",
"]",
">=",
"threshold",
")",
"{",
"count",
"++",
";",
"}",
"}",
"return",
"count",
";",
"}"
] | Returns the matrix's rank. Automatic selection of threshold
@param A Matrix. Not modified.
@return The rank of the decomposed matrix. | [
"Returns",
"the",
"matrix",
"s",
"rank",
".",
"Automatic",
"selection",
"of",
"threshold"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L129-L150 |
162,323 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.checkSvdMatrixSize | public static void checkSvdMatrixSize(DMatrixRMaj U, boolean tranU, DMatrixRMaj W, DMatrixRMaj V, boolean tranV ) {
int numSingular = Math.min(W.numRows,W.numCols);
boolean compact = W.numRows == W.numCols;
if( compact ) {
if( U != null ) {
if( tranU && U.numRows != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix U");
else if( !tranU && U.numCols != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix U");
}
if( V != null ) {
if( tranV && V.numRows != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix V");
else if( !tranV && V.numCols != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix V");
}
} else {
if( U != null && U.numRows != U.numCols )
throw new IllegalArgumentException("Unexpected size of matrix U");
if( V != null && V.numRows != V.numCols )
throw new IllegalArgumentException("Unexpected size of matrix V");
if( U != null && U.numRows != W.numRows )
throw new IllegalArgumentException("Unexpected size of W");
if( V != null && V.numRows != W.numCols )
throw new IllegalArgumentException("Unexpected size of W");
}
} | java | public static void checkSvdMatrixSize(DMatrixRMaj U, boolean tranU, DMatrixRMaj W, DMatrixRMaj V, boolean tranV ) {
int numSingular = Math.min(W.numRows,W.numCols);
boolean compact = W.numRows == W.numCols;
if( compact ) {
if( U != null ) {
if( tranU && U.numRows != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix U");
else if( !tranU && U.numCols != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix U");
}
if( V != null ) {
if( tranV && V.numRows != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix V");
else if( !tranV && V.numCols != numSingular )
throw new IllegalArgumentException("Unexpected size of matrix V");
}
} else {
if( U != null && U.numRows != U.numCols )
throw new IllegalArgumentException("Unexpected size of matrix U");
if( V != null && V.numRows != V.numCols )
throw new IllegalArgumentException("Unexpected size of matrix V");
if( U != null && U.numRows != W.numRows )
throw new IllegalArgumentException("Unexpected size of W");
if( V != null && V.numRows != W.numCols )
throw new IllegalArgumentException("Unexpected size of W");
}
} | [
"public",
"static",
"void",
"checkSvdMatrixSize",
"(",
"DMatrixRMaj",
"U",
",",
"boolean",
"tranU",
",",
"DMatrixRMaj",
"W",
",",
"DMatrixRMaj",
"V",
",",
"boolean",
"tranV",
")",
"{",
"int",
"numSingular",
"=",
"Math",
".",
"min",
"(",
"W",
".",
"numRows",
",",
"W",
".",
"numCols",
")",
";",
"boolean",
"compact",
"=",
"W",
".",
"numRows",
"==",
"W",
".",
"numCols",
";",
"if",
"(",
"compact",
")",
"{",
"if",
"(",
"U",
"!=",
"null",
")",
"{",
"if",
"(",
"tranU",
"&&",
"U",
".",
"numRows",
"!=",
"numSingular",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix U\"",
")",
";",
"else",
"if",
"(",
"!",
"tranU",
"&&",
"U",
".",
"numCols",
"!=",
"numSingular",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix U\"",
")",
";",
"}",
"if",
"(",
"V",
"!=",
"null",
")",
"{",
"if",
"(",
"tranV",
"&&",
"V",
".",
"numRows",
"!=",
"numSingular",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix V\"",
")",
";",
"else",
"if",
"(",
"!",
"tranV",
"&&",
"V",
".",
"numCols",
"!=",
"numSingular",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix V\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"U",
"!=",
"null",
"&&",
"U",
".",
"numRows",
"!=",
"U",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix U\"",
")",
";",
"if",
"(",
"V",
"!=",
"null",
"&&",
"V",
".",
"numRows",
"!=",
"V",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of matrix V\"",
")",
";",
"if",
"(",
"U",
"!=",
"null",
"&&",
"U",
".",
"numRows",
"!=",
"W",
".",
"numRows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of W\"",
")",
";",
"if",
"(",
"V",
"!=",
"null",
"&&",
"V",
".",
"numRows",
"!=",
"W",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected size of W\"",
")",
";",
"}",
"}"
] | Checks to see if all the provided matrices are the expected size for an SVD. If an error is encountered
then an exception is thrown. This automatically handles compact and non-compact formats | [
"Checks",
"to",
"see",
"if",
"all",
"the",
"provided",
"matrices",
"are",
"the",
"expected",
"size",
"for",
"an",
"SVD",
".",
"If",
"an",
"error",
"is",
"encountered",
"then",
"an",
"exception",
"is",
"thrown",
".",
"This",
"automatically",
"handles",
"compact",
"and",
"non",
"-",
"compact",
"formats"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L319-L347 |
162,324 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.nullspaceQR | public static DMatrixRMaj nullspaceQR( DMatrixRMaj A , int totalSingular ) {
SolveNullSpaceQR_DDRM solver = new SolveNullSpaceQR_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | java | public static DMatrixRMaj nullspaceQR( DMatrixRMaj A , int totalSingular ) {
SolveNullSpaceQR_DDRM solver = new SolveNullSpaceQR_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | [
"public",
"static",
"DMatrixRMaj",
"nullspaceQR",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"totalSingular",
")",
"{",
"SolveNullSpaceQR_DDRM",
"solver",
"=",
"new",
"SolveNullSpaceQR_DDRM",
"(",
")",
";",
"DMatrixRMaj",
"nullspace",
"=",
"new",
"DMatrixRMaj",
"(",
"1",
",",
"1",
")",
";",
"if",
"(",
"!",
"solver",
".",
"process",
"(",
"A",
",",
"totalSingular",
",",
"nullspace",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Solver failed. try SVD based method instead?\"",
")",
";",
"return",
"nullspace",
";",
"}"
] | Computes the null space using QR decomposition. This is much faster than using SVD
@param A (Input) Matrix
@param totalSingular Number of singular values
@return Null space | [
"Computes",
"the",
"null",
"space",
"using",
"QR",
"decomposition",
".",
"This",
"is",
"much",
"faster",
"than",
"using",
"SVD"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L434-L443 |
162,325 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.nullspaceQRP | public static DMatrixRMaj nullspaceQRP( DMatrixRMaj A , int totalSingular ) {
SolveNullSpaceQRP_DDRM solver = new SolveNullSpaceQRP_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | java | public static DMatrixRMaj nullspaceQRP( DMatrixRMaj A , int totalSingular ) {
SolveNullSpaceQRP_DDRM solver = new SolveNullSpaceQRP_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | [
"public",
"static",
"DMatrixRMaj",
"nullspaceQRP",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"totalSingular",
")",
"{",
"SolveNullSpaceQRP_DDRM",
"solver",
"=",
"new",
"SolveNullSpaceQRP_DDRM",
"(",
")",
";",
"DMatrixRMaj",
"nullspace",
"=",
"new",
"DMatrixRMaj",
"(",
"1",
",",
"1",
")",
";",
"if",
"(",
"!",
"solver",
".",
"process",
"(",
"A",
",",
"totalSingular",
",",
"nullspace",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Solver failed. try SVD based method instead?\"",
")",
";",
"return",
"nullspace",
";",
"}"
] | Computes the null space using QRP decomposition. This is faster than using SVD but slower than QR.
Much more stable than QR though.
@param A (Input) Matrix
@param totalSingular Number of singular values
@return Null space | [
"Computes",
"the",
"null",
"space",
"using",
"QRP",
"decomposition",
".",
"This",
"is",
"faster",
"than",
"using",
"SVD",
"but",
"slower",
"than",
"QR",
".",
"Much",
"more",
"stable",
"than",
"QR",
"though",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L452-L461 |
162,326 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.nullspaceSVD | public static DMatrixRMaj nullspaceSVD( DMatrixRMaj A , int totalSingular ) {
SolveNullSpace<DMatrixRMaj> solver = new SolveNullSpaceSvd_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | java | public static DMatrixRMaj nullspaceSVD( DMatrixRMaj A , int totalSingular ) {
SolveNullSpace<DMatrixRMaj> solver = new SolveNullSpaceSvd_DDRM();
DMatrixRMaj nullspace = new DMatrixRMaj(1,1);
if( !solver.process(A,totalSingular,nullspace))
throw new RuntimeException("Solver failed. try SVD based method instead?");
return nullspace;
} | [
"public",
"static",
"DMatrixRMaj",
"nullspaceSVD",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"totalSingular",
")",
"{",
"SolveNullSpace",
"<",
"DMatrixRMaj",
">",
"solver",
"=",
"new",
"SolveNullSpaceSvd_DDRM",
"(",
")",
";",
"DMatrixRMaj",
"nullspace",
"=",
"new",
"DMatrixRMaj",
"(",
"1",
",",
"1",
")",
";",
"if",
"(",
"!",
"solver",
".",
"process",
"(",
"A",
",",
"totalSingular",
",",
"nullspace",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Solver failed. try SVD based method instead?\"",
")",
";",
"return",
"nullspace",
";",
"}"
] | Computes the null space using SVD. Slowest bust most stable way to find the solution
@param A (Input) Matrix
@param totalSingular Number of singular values
@return Null space | [
"Computes",
"the",
"null",
"space",
"using",
"SVD",
".",
"Slowest",
"bust",
"most",
"stable",
"way",
"to",
"find",
"the",
"solution"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L470-L479 |
162,327 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.rank | public static int rank(SingularValueDecomposition_F64 svd , double threshold ) {
int numRank=0;
double w[]= svd.getSingularValues();
int N = svd.numberOfSingularValues();
for( int j = 0; j < N; j++ ) {
if( w[j] > threshold)
numRank++;
}
return numRank;
} | java | public static int rank(SingularValueDecomposition_F64 svd , double threshold ) {
int numRank=0;
double w[]= svd.getSingularValues();
int N = svd.numberOfSingularValues();
for( int j = 0; j < N; j++ ) {
if( w[j] > threshold)
numRank++;
}
return numRank;
} | [
"public",
"static",
"int",
"rank",
"(",
"SingularValueDecomposition_F64",
"svd",
",",
"double",
"threshold",
")",
"{",
"int",
"numRank",
"=",
"0",
";",
"double",
"w",
"[",
"]",
"=",
"svd",
".",
"getSingularValues",
"(",
")",
";",
"int",
"N",
"=",
"svd",
".",
"numberOfSingularValues",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"N",
";",
"j",
"++",
")",
"{",
"if",
"(",
"w",
"[",
"j",
"]",
">",
"threshold",
")",
"numRank",
"++",
";",
"}",
"return",
"numRank",
";",
"}"
] | Extracts the rank of a matrix using a preexisting decomposition.
@see #singularThreshold(SingularValueDecomposition_F64)
@param svd A precomputed decomposition. Not modified.
@param threshold Tolerance used to determine of a singular value is singular.
@return The rank of the decomposed matrix. | [
"Extracts",
"the",
"rank",
"of",
"a",
"matrix",
"using",
"a",
"preexisting",
"decomposition",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L608-L621 |
162,328 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java | SingularOps_DDRM.nullity | public static int nullity(SingularValueDecomposition_F64 svd , double threshold ) {
int ret = 0;
double w[]= svd.getSingularValues();
int N = svd.numberOfSingularValues();
int numCol = svd.numCols();
for( int j = 0; j < N; j++ ) {
if( w[j] <= threshold) ret++;
}
return ret + numCol-N;
} | java | public static int nullity(SingularValueDecomposition_F64 svd , double threshold ) {
int ret = 0;
double w[]= svd.getSingularValues();
int N = svd.numberOfSingularValues();
int numCol = svd.numCols();
for( int j = 0; j < N; j++ ) {
if( w[j] <= threshold) ret++;
}
return ret + numCol-N;
} | [
"public",
"static",
"int",
"nullity",
"(",
"SingularValueDecomposition_F64",
"svd",
",",
"double",
"threshold",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"double",
"w",
"[",
"]",
"=",
"svd",
".",
"getSingularValues",
"(",
")",
";",
"int",
"N",
"=",
"svd",
".",
"numberOfSingularValues",
"(",
")",
";",
"int",
"numCol",
"=",
"svd",
".",
"numCols",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"N",
";",
"j",
"++",
")",
"{",
"if",
"(",
"w",
"[",
"j",
"]",
"<=",
"threshold",
")",
"ret",
"++",
";",
"}",
"return",
"ret",
"+",
"numCol",
"-",
"N",
";",
"}"
] | Extracts the nullity of a matrix using a preexisting decomposition.
@see #singularThreshold(SingularValueDecomposition_F64)
@param svd A precomputed decomposition. Not modified.
@param threshold Tolerance used to determine of a singular value is singular.
@return The nullity of the decomposed matrix. | [
"Extracts",
"the",
"nullity",
"of",
"a",
"matrix",
"using",
"a",
"preexisting",
"decomposition",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L645-L658 |
162,329 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleSVD.java | SimpleSVD.getSingularValues | public double[] getSingularValues() {
double ret[] = new double[W.numCols()];
for (int i = 0; i < ret.length; i++) {
ret[i] = getSingleValue(i);
}
return ret;
} | java | public double[] getSingularValues() {
double ret[] = new double[W.numCols()];
for (int i = 0; i < ret.length; i++) {
ret[i] = getSingleValue(i);
}
return ret;
} | [
"public",
"double",
"[",
"]",
"getSingularValues",
"(",
")",
"{",
"double",
"ret",
"[",
"]",
"=",
"new",
"double",
"[",
"W",
".",
"numCols",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ret",
".",
"length",
";",
"i",
"++",
")",
"{",
"ret",
"[",
"i",
"]",
"=",
"getSingleValue",
"(",
"i",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Returns an array of all the singular values | [
"Returns",
"an",
"array",
"of",
"all",
"the",
"singular",
"values"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleSVD.java#L176-L183 |
162,330 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleSVD.java | SimpleSVD.rank | public int rank() {
if( is64 ) {
return SingularOps_DDRM.rank((SingularValueDecomposition_F64)svd, tol);
} else {
return SingularOps_FDRM.rank((SingularValueDecomposition_F32)svd, (float)tol);
}
} | java | public int rank() {
if( is64 ) {
return SingularOps_DDRM.rank((SingularValueDecomposition_F64)svd, tol);
} else {
return SingularOps_FDRM.rank((SingularValueDecomposition_F32)svd, (float)tol);
}
} | [
"public",
"int",
"rank",
"(",
")",
"{",
"if",
"(",
"is64",
")",
"{",
"return",
"SingularOps_DDRM",
".",
"rank",
"(",
"(",
"SingularValueDecomposition_F64",
")",
"svd",
",",
"tol",
")",
";",
"}",
"else",
"{",
"return",
"SingularOps_FDRM",
".",
"rank",
"(",
"(",
"SingularValueDecomposition_F32",
")",
"svd",
",",
"(",
"float",
")",
"tol",
")",
";",
"}",
"}"
] | Returns the rank of the decomposed matrix.
@see SingularOps_DDRM#rank(SingularValueDecomposition_F64, double)
@return The matrix's rank | [
"Returns",
"the",
"rank",
"of",
"the",
"decomposed",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleSVD.java#L192-L198 |
162,331 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleSVD.java | SimpleSVD.nullity | public int nullity() {
if( is64 ) {
return SingularOps_DDRM.nullity((SingularValueDecomposition_F64)svd, 10.0 * UtilEjml.EPS);
} else {
return SingularOps_FDRM.nullity((SingularValueDecomposition_F32)svd, 5.0f * UtilEjml.F_EPS);
}
} | java | public int nullity() {
if( is64 ) {
return SingularOps_DDRM.nullity((SingularValueDecomposition_F64)svd, 10.0 * UtilEjml.EPS);
} else {
return SingularOps_FDRM.nullity((SingularValueDecomposition_F32)svd, 5.0f * UtilEjml.F_EPS);
}
} | [
"public",
"int",
"nullity",
"(",
")",
"{",
"if",
"(",
"is64",
")",
"{",
"return",
"SingularOps_DDRM",
".",
"nullity",
"(",
"(",
"SingularValueDecomposition_F64",
")",
"svd",
",",
"10.0",
"*",
"UtilEjml",
".",
"EPS",
")",
";",
"}",
"else",
"{",
"return",
"SingularOps_FDRM",
".",
"nullity",
"(",
"(",
"SingularValueDecomposition_F32",
")",
"svd",
",",
"5.0f",
"*",
"UtilEjml",
".",
"F_EPS",
")",
";",
"}",
"}"
] | The nullity of the decomposed matrix.
@see SingularOps_DDRM#nullity(SingularValueDecomposition_F64, double)
@return The matrix's nullity | [
"The",
"nullity",
"of",
"the",
"decomposed",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleSVD.java#L207-L213 |
162,332 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java | ManagerFunctions.isFunctionName | public boolean isFunctionName( String s ) {
if( input1.containsKey(s))
return true;
if( inputN.containsKey(s))
return true;
return false;
} | java | public boolean isFunctionName( String s ) {
if( input1.containsKey(s))
return true;
if( inputN.containsKey(s))
return true;
return false;
} | [
"public",
"boolean",
"isFunctionName",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"input1",
".",
"containsKey",
"(",
"s",
")",
")",
"return",
"true",
";",
"if",
"(",
"inputN",
".",
"containsKey",
"(",
"s",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Returns true if the string matches the name of a function | [
"Returns",
"true",
"if",
"the",
"string",
"matches",
"the",
"name",
"of",
"a",
"function"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java#L47-L54 |
162,333 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java | ManagerFunctions.create | public Operation.Info create( char op , Variable input ) {
switch( op ) {
case '\'':
return Operation.transpose(input, managerTemp);
default:
throw new RuntimeException("Unknown operation " + op);
}
} | java | public Operation.Info create( char op , Variable input ) {
switch( op ) {
case '\'':
return Operation.transpose(input, managerTemp);
default:
throw new RuntimeException("Unknown operation " + op);
}
} | [
"public",
"Operation",
".",
"Info",
"create",
"(",
"char",
"op",
",",
"Variable",
"input",
")",
"{",
"switch",
"(",
"op",
")",
"{",
"case",
"'",
"'",
":",
"return",
"Operation",
".",
"transpose",
"(",
"input",
",",
"managerTemp",
")",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Unknown operation \"",
"+",
"op",
")",
";",
"}",
"}"
] | Create a new instance of a single input function from an operator character
@param op Which operation
@param input Input variable
@return Resulting operation | [
"Create",
"a",
"new",
"instance",
"of",
"a",
"single",
"input",
"function",
"from",
"an",
"operator",
"character"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java#L88-L96 |
162,334 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java | ManagerFunctions.create | public Operation.Info create( Symbol op , Variable left , Variable right ) {
switch( op ) {
case PLUS:
return Operation.add(left, right, managerTemp);
case MINUS:
return Operation.subtract(left, right, managerTemp);
case TIMES:
return Operation.multiply(left, right, managerTemp);
case RDIVIDE:
return Operation.divide(left, right, managerTemp);
case LDIVIDE:
return Operation.divide(right, left, managerTemp);
case POWER:
return Operation.pow(left, right, managerTemp);
case ELEMENT_DIVIDE:
return Operation.elementDivision(left, right, managerTemp);
case ELEMENT_TIMES:
return Operation.elementMult(left, right, managerTemp);
case ELEMENT_POWER:
return Operation.elementPow(left, right, managerTemp);
default:
throw new RuntimeException("Unknown operation " + op);
}
} | java | public Operation.Info create( Symbol op , Variable left , Variable right ) {
switch( op ) {
case PLUS:
return Operation.add(left, right, managerTemp);
case MINUS:
return Operation.subtract(left, right, managerTemp);
case TIMES:
return Operation.multiply(left, right, managerTemp);
case RDIVIDE:
return Operation.divide(left, right, managerTemp);
case LDIVIDE:
return Operation.divide(right, left, managerTemp);
case POWER:
return Operation.pow(left, right, managerTemp);
case ELEMENT_DIVIDE:
return Operation.elementDivision(left, right, managerTemp);
case ELEMENT_TIMES:
return Operation.elementMult(left, right, managerTemp);
case ELEMENT_POWER:
return Operation.elementPow(left, right, managerTemp);
default:
throw new RuntimeException("Unknown operation " + op);
}
} | [
"public",
"Operation",
".",
"Info",
"create",
"(",
"Symbol",
"op",
",",
"Variable",
"left",
",",
"Variable",
"right",
")",
"{",
"switch",
"(",
"op",
")",
"{",
"case",
"PLUS",
":",
"return",
"Operation",
".",
"add",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"MINUS",
":",
"return",
"Operation",
".",
"subtract",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"TIMES",
":",
"return",
"Operation",
".",
"multiply",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"RDIVIDE",
":",
"return",
"Operation",
".",
"divide",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"LDIVIDE",
":",
"return",
"Operation",
".",
"divide",
"(",
"right",
",",
"left",
",",
"managerTemp",
")",
";",
"case",
"POWER",
":",
"return",
"Operation",
".",
"pow",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"ELEMENT_DIVIDE",
":",
"return",
"Operation",
".",
"elementDivision",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"ELEMENT_TIMES",
":",
"return",
"Operation",
".",
"elementMult",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"case",
"ELEMENT_POWER",
":",
"return",
"Operation",
".",
"elementPow",
"(",
"left",
",",
"right",
",",
"managerTemp",
")",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Unknown operation \"",
"+",
"op",
")",
";",
"}",
"}"
] | Create a new instance of a two input function from an operator character
@param op Which operation
@param left Input variable on left
@param right Input variable on right
@return Resulting operation | [
"Create",
"a",
"new",
"instance",
"of",
"a",
"two",
"input",
"function",
"from",
"an",
"operator",
"character"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/ManagerFunctions.java#L105-L137 |
162,335 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/misc/ColumnCounts_DSCC.java | ColumnCounts_DSCC.initialize | void initialize(DMatrixSparseCSC A) {
m = A.numRows;
n = A.numCols;
int s = 4*n + (ata ? (n+m+1) : 0);
gw.reshape(s);
w = gw.data;
// compute the transpose of A
At.reshape(A.numCols,A.numRows,A.nz_length);
CommonOps_DSCC.transpose(A,At,gw);
// initialize w
Arrays.fill(w,0,s,-1); // assign all values in workspace to -1
ancestor = 0;
maxfirst = n;
prevleaf = 2*n;
first = 3*n;
} | java | void initialize(DMatrixSparseCSC A) {
m = A.numRows;
n = A.numCols;
int s = 4*n + (ata ? (n+m+1) : 0);
gw.reshape(s);
w = gw.data;
// compute the transpose of A
At.reshape(A.numCols,A.numRows,A.nz_length);
CommonOps_DSCC.transpose(A,At,gw);
// initialize w
Arrays.fill(w,0,s,-1); // assign all values in workspace to -1
ancestor = 0;
maxfirst = n;
prevleaf = 2*n;
first = 3*n;
} | [
"void",
"initialize",
"(",
"DMatrixSparseCSC",
"A",
")",
"{",
"m",
"=",
"A",
".",
"numRows",
";",
"n",
"=",
"A",
".",
"numCols",
";",
"int",
"s",
"=",
"4",
"*",
"n",
"+",
"(",
"ata",
"?",
"(",
"n",
"+",
"m",
"+",
"1",
")",
":",
"0",
")",
";",
"gw",
".",
"reshape",
"(",
"s",
")",
";",
"w",
"=",
"gw",
".",
"data",
";",
"// compute the transpose of A",
"At",
".",
"reshape",
"(",
"A",
".",
"numCols",
",",
"A",
".",
"numRows",
",",
"A",
".",
"nz_length",
")",
";",
"CommonOps_DSCC",
".",
"transpose",
"(",
"A",
",",
"At",
",",
"gw",
")",
";",
"// initialize w",
"Arrays",
".",
"fill",
"(",
"w",
",",
"0",
",",
"s",
",",
"-",
"1",
")",
";",
"// assign all values in workspace to -1",
"ancestor",
"=",
"0",
";",
"maxfirst",
"=",
"n",
";",
"prevleaf",
"=",
"2",
"*",
"n",
";",
"first",
"=",
"3",
"*",
"n",
";",
"}"
] | Initializes class data structures and parameters | [
"Initializes",
"class",
"data",
"structures",
"and",
"parameters"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/misc/ColumnCounts_DSCC.java#L74-L93 |
162,336 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/misc/ColumnCounts_DSCC.java | ColumnCounts_DSCC.process | public void process(DMatrixSparseCSC A , int parent[], int post[], int counts[] ) {
if( counts.length < A.numCols )
throw new IllegalArgumentException("counts must be at least of length A.numCols");
initialize(A);
int delta[] = counts;
findFirstDescendant(parent, post, delta);
if( ata ) {
init_ata(post);
}
for (int i = 0; i < n; i++)
w[ancestor+i] = i;
int[] ATp = At.col_idx; int []ATi = At.nz_rows;
for (int k = 0; k < n; k++) {
int j = post[k];
if( parent[j] != -1 )
delta[parent[j]]--; // j is not a root
for (int J = HEAD(k,j); J != -1; J = NEXT(J)) {
for (int p = ATp[J]; p < ATp[J+1]; p++) {
int i = ATi[p];
int q = isLeaf(i,j);
if( jleaf >= 1)
delta[j]++;
if( jleaf == 2 )
delta[q]--;
}
}
if( parent[j] != -1 )
w[ancestor+j] = parent[j];
}
// sum up delta's of each child
for ( int j = 0; j < n; j++) {
if( parent[j] != -1)
counts[parent[j]] += counts[j];
}
} | java | public void process(DMatrixSparseCSC A , int parent[], int post[], int counts[] ) {
if( counts.length < A.numCols )
throw new IllegalArgumentException("counts must be at least of length A.numCols");
initialize(A);
int delta[] = counts;
findFirstDescendant(parent, post, delta);
if( ata ) {
init_ata(post);
}
for (int i = 0; i < n; i++)
w[ancestor+i] = i;
int[] ATp = At.col_idx; int []ATi = At.nz_rows;
for (int k = 0; k < n; k++) {
int j = post[k];
if( parent[j] != -1 )
delta[parent[j]]--; // j is not a root
for (int J = HEAD(k,j); J != -1; J = NEXT(J)) {
for (int p = ATp[J]; p < ATp[J+1]; p++) {
int i = ATi[p];
int q = isLeaf(i,j);
if( jleaf >= 1)
delta[j]++;
if( jleaf == 2 )
delta[q]--;
}
}
if( parent[j] != -1 )
w[ancestor+j] = parent[j];
}
// sum up delta's of each child
for ( int j = 0; j < n; j++) {
if( parent[j] != -1)
counts[parent[j]] += counts[j];
}
} | [
"public",
"void",
"process",
"(",
"DMatrixSparseCSC",
"A",
",",
"int",
"parent",
"[",
"]",
",",
"int",
"post",
"[",
"]",
",",
"int",
"counts",
"[",
"]",
")",
"{",
"if",
"(",
"counts",
".",
"length",
"<",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"counts must be at least of length A.numCols\"",
")",
";",
"initialize",
"(",
"A",
")",
";",
"int",
"delta",
"[",
"]",
"=",
"counts",
";",
"findFirstDescendant",
"(",
"parent",
",",
"post",
",",
"delta",
")",
";",
"if",
"(",
"ata",
")",
"{",
"init_ata",
"(",
"post",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"w",
"[",
"ancestor",
"+",
"i",
"]",
"=",
"i",
";",
"int",
"[",
"]",
"ATp",
"=",
"At",
".",
"col_idx",
";",
"int",
"[",
"]",
"ATi",
"=",
"At",
".",
"nz_rows",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"n",
";",
"k",
"++",
")",
"{",
"int",
"j",
"=",
"post",
"[",
"k",
"]",
";",
"if",
"(",
"parent",
"[",
"j",
"]",
"!=",
"-",
"1",
")",
"delta",
"[",
"parent",
"[",
"j",
"]",
"]",
"--",
";",
"// j is not a root",
"for",
"(",
"int",
"J",
"=",
"HEAD",
"(",
"k",
",",
"j",
")",
";",
"J",
"!=",
"-",
"1",
";",
"J",
"=",
"NEXT",
"(",
"J",
")",
")",
"{",
"for",
"(",
"int",
"p",
"=",
"ATp",
"[",
"J",
"]",
";",
"p",
"<",
"ATp",
"[",
"J",
"+",
"1",
"]",
";",
"p",
"++",
")",
"{",
"int",
"i",
"=",
"ATi",
"[",
"p",
"]",
";",
"int",
"q",
"=",
"isLeaf",
"(",
"i",
",",
"j",
")",
";",
"if",
"(",
"jleaf",
">=",
"1",
")",
"delta",
"[",
"j",
"]",
"++",
";",
"if",
"(",
"jleaf",
"==",
"2",
")",
"delta",
"[",
"q",
"]",
"--",
";",
"}",
"}",
"if",
"(",
"parent",
"[",
"j",
"]",
"!=",
"-",
"1",
")",
"w",
"[",
"ancestor",
"+",
"j",
"]",
"=",
"parent",
"[",
"j",
"]",
";",
"}",
"// sum up delta's of each child",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"parent",
"[",
"j",
"]",
"!=",
"-",
"1",
")",
"counts",
"[",
"parent",
"[",
"j",
"]",
"]",
"+=",
"counts",
"[",
"j",
"]",
";",
"}",
"}"
] | Processes and computes column counts of A
@param A (Input) Upper triangular matrix
@param parent (Input) Elimination tree.
@param post (Input) Post order permutation of elimination tree. See {@link TriangularSolver_DSCC#postorder}
@param counts (Output) Storage for column counts. | [
"Processes",
"and",
"computes",
"column",
"counts",
"of",
"A"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/misc/ColumnCounts_DSCC.java#L103-L143 |
162,337 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/DMatrixVisualization.java | DMatrixVisualization.show | public static void show(DMatrixD1 A , String title ) {
JFrame frame = new JFrame(title);
int width = 300;
int height = 300;
if( A.numRows > A.numCols) {
width = width*A.numCols/A.numRows;
} else {
height = height*A.numRows/A.numCols;
}
DMatrixComponent panel = new DMatrixComponent(width,height);
panel.setMatrix(A);
frame.add(panel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
} | java | public static void show(DMatrixD1 A , String title ) {
JFrame frame = new JFrame(title);
int width = 300;
int height = 300;
if( A.numRows > A.numCols) {
width = width*A.numCols/A.numRows;
} else {
height = height*A.numRows/A.numCols;
}
DMatrixComponent panel = new DMatrixComponent(width,height);
panel.setMatrix(A);
frame.add(panel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
} | [
"public",
"static",
"void",
"show",
"(",
"DMatrixD1",
"A",
",",
"String",
"title",
")",
"{",
"JFrame",
"frame",
"=",
"new",
"JFrame",
"(",
"title",
")",
";",
"int",
"width",
"=",
"300",
";",
"int",
"height",
"=",
"300",
";",
"if",
"(",
"A",
".",
"numRows",
">",
"A",
".",
"numCols",
")",
"{",
"width",
"=",
"width",
"*",
"A",
".",
"numCols",
"/",
"A",
".",
"numRows",
";",
"}",
"else",
"{",
"height",
"=",
"height",
"*",
"A",
".",
"numRows",
"/",
"A",
".",
"numCols",
";",
"}",
"DMatrixComponent",
"panel",
"=",
"new",
"DMatrixComponent",
"(",
"width",
",",
"height",
")",
";",
"panel",
".",
"setMatrix",
"(",
"A",
")",
";",
"frame",
".",
"add",
"(",
"panel",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"frame",
".",
"pack",
"(",
")",
";",
"frame",
".",
"setVisible",
"(",
"true",
")",
";",
"}"
] | Creates a window visually showing the matrix's state. Block means an element is zero.
Red positive and blue negative. More intense the color larger the element's absolute value
is.
@param A A matrix.
@param title Name of the window. | [
"Creates",
"a",
"window",
"visually",
"showing",
"the",
"matrix",
"s",
"state",
".",
"Block",
"means",
"an",
"element",
"is",
"zero",
".",
"Red",
"positive",
"and",
"blue",
"negative",
".",
"More",
"intense",
"the",
"color",
"larger",
"the",
"element",
"s",
"absolute",
"value",
"is",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/DMatrixVisualization.java#L48-L68 |
162,338 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java | EigenvalueSmall_F64.value2x2 | public void value2x2( double a11 , double a12, double a21 , double a22 )
{
// apply a rotators such that th a11 and a22 elements are the same
double c,s;
if( a12 + a21 == 0 ) { // is this pointless since
c = s = 1.0 / Math.sqrt(2);
} else {
double aa = (a11-a22);
double bb = (a12+a21);
double t_hat = aa/bb;
double t = t_hat/(1.0 + Math.sqrt(1.0+t_hat*t_hat));
c = 1.0/ Math.sqrt(1.0+t*t);
s = c*t;
}
double c2 = c*c;
double s2 = s*s;
double cs = c*s;
double b11 = c2*a11 + s2*a22 - cs*(a12+a21);
double b12 = c2*a12 - s2*a21 + cs*(a11-a22);
double b21 = c2*a21 - s2*a12 + cs*(a11-a22);
// double b22 = c2*a22 + s2*a11 + cs*(a12+a21);
// apply second rotator to make A upper triangular if real eigenvalues
if( b21*b12 >= 0 ) {
if( b12 == 0 ) {
c = 0;
s = 1;
} else {
s = Math.sqrt(b21/(b12+b21));
c = Math.sqrt(b12/(b12+b21));
}
// c2 = b12;//c*c;
// s2 = b21;//s*s;
cs = c*s;
a11 = b11 - cs*(b12 + b21);
// a12 = c2*b12 - s2*b21;
// a21 = c2*b21 - s2*b12;
a22 = b11 + cs*(b12 + b21);
value0.real = a11;
value1.real = a22;
value0.imaginary = value1.imaginary = 0;
} else {
value0.real = value1.real = b11;
value0.imaginary = Math.sqrt(-b21*b12);
value1.imaginary = -value0.imaginary;
}
} | java | public void value2x2( double a11 , double a12, double a21 , double a22 )
{
// apply a rotators such that th a11 and a22 elements are the same
double c,s;
if( a12 + a21 == 0 ) { // is this pointless since
c = s = 1.0 / Math.sqrt(2);
} else {
double aa = (a11-a22);
double bb = (a12+a21);
double t_hat = aa/bb;
double t = t_hat/(1.0 + Math.sqrt(1.0+t_hat*t_hat));
c = 1.0/ Math.sqrt(1.0+t*t);
s = c*t;
}
double c2 = c*c;
double s2 = s*s;
double cs = c*s;
double b11 = c2*a11 + s2*a22 - cs*(a12+a21);
double b12 = c2*a12 - s2*a21 + cs*(a11-a22);
double b21 = c2*a21 - s2*a12 + cs*(a11-a22);
// double b22 = c2*a22 + s2*a11 + cs*(a12+a21);
// apply second rotator to make A upper triangular if real eigenvalues
if( b21*b12 >= 0 ) {
if( b12 == 0 ) {
c = 0;
s = 1;
} else {
s = Math.sqrt(b21/(b12+b21));
c = Math.sqrt(b12/(b12+b21));
}
// c2 = b12;//c*c;
// s2 = b21;//s*s;
cs = c*s;
a11 = b11 - cs*(b12 + b21);
// a12 = c2*b12 - s2*b21;
// a21 = c2*b21 - s2*b12;
a22 = b11 + cs*(b12 + b21);
value0.real = a11;
value1.real = a22;
value0.imaginary = value1.imaginary = 0;
} else {
value0.real = value1.real = b11;
value0.imaginary = Math.sqrt(-b21*b12);
value1.imaginary = -value0.imaginary;
}
} | [
"public",
"void",
"value2x2",
"(",
"double",
"a11",
",",
"double",
"a12",
",",
"double",
"a21",
",",
"double",
"a22",
")",
"{",
"// apply a rotators such that th a11 and a22 elements are the same",
"double",
"c",
",",
"s",
";",
"if",
"(",
"a12",
"+",
"a21",
"==",
"0",
")",
"{",
"// is this pointless since",
"c",
"=",
"s",
"=",
"1.0",
"/",
"Math",
".",
"sqrt",
"(",
"2",
")",
";",
"}",
"else",
"{",
"double",
"aa",
"=",
"(",
"a11",
"-",
"a22",
")",
";",
"double",
"bb",
"=",
"(",
"a12",
"+",
"a21",
")",
";",
"double",
"t_hat",
"=",
"aa",
"/",
"bb",
";",
"double",
"t",
"=",
"t_hat",
"/",
"(",
"1.0",
"+",
"Math",
".",
"sqrt",
"(",
"1.0",
"+",
"t_hat",
"*",
"t_hat",
")",
")",
";",
"c",
"=",
"1.0",
"/",
"Math",
".",
"sqrt",
"(",
"1.0",
"+",
"t",
"*",
"t",
")",
";",
"s",
"=",
"c",
"*",
"t",
";",
"}",
"double",
"c2",
"=",
"c",
"*",
"c",
";",
"double",
"s2",
"=",
"s",
"*",
"s",
";",
"double",
"cs",
"=",
"c",
"*",
"s",
";",
"double",
"b11",
"=",
"c2",
"*",
"a11",
"+",
"s2",
"*",
"a22",
"-",
"cs",
"*",
"(",
"a12",
"+",
"a21",
")",
";",
"double",
"b12",
"=",
"c2",
"*",
"a12",
"-",
"s2",
"*",
"a21",
"+",
"cs",
"*",
"(",
"a11",
"-",
"a22",
")",
";",
"double",
"b21",
"=",
"c2",
"*",
"a21",
"-",
"s2",
"*",
"a12",
"+",
"cs",
"*",
"(",
"a11",
"-",
"a22",
")",
";",
"// double b22 = c2*a22 + s2*a11 + cs*(a12+a21);",
"// apply second rotator to make A upper triangular if real eigenvalues",
"if",
"(",
"b21",
"*",
"b12",
">=",
"0",
")",
"{",
"if",
"(",
"b12",
"==",
"0",
")",
"{",
"c",
"=",
"0",
";",
"s",
"=",
"1",
";",
"}",
"else",
"{",
"s",
"=",
"Math",
".",
"sqrt",
"(",
"b21",
"/",
"(",
"b12",
"+",
"b21",
")",
")",
";",
"c",
"=",
"Math",
".",
"sqrt",
"(",
"b12",
"/",
"(",
"b12",
"+",
"b21",
")",
")",
";",
"}",
"// c2 = b12;//c*c;",
"// s2 = b21;//s*s;",
"cs",
"=",
"c",
"*",
"s",
";",
"a11",
"=",
"b11",
"-",
"cs",
"*",
"(",
"b12",
"+",
"b21",
")",
";",
"// a12 = c2*b12 - s2*b21;",
"// a21 = c2*b21 - s2*b12;",
"a22",
"=",
"b11",
"+",
"cs",
"*",
"(",
"b12",
"+",
"b21",
")",
";",
"value0",
".",
"real",
"=",
"a11",
";",
"value1",
".",
"real",
"=",
"a22",
";",
"value0",
".",
"imaginary",
"=",
"value1",
".",
"imaginary",
"=",
"0",
";",
"}",
"else",
"{",
"value0",
".",
"real",
"=",
"value1",
".",
"real",
"=",
"b11",
";",
"value0",
".",
"imaginary",
"=",
"Math",
".",
"sqrt",
"(",
"-",
"b21",
"*",
"b12",
")",
";",
"value1",
".",
"imaginary",
"=",
"-",
"value0",
".",
"imaginary",
";",
"}",
"}"
] | if |a11-a22| >> |a12+a21| there might be a better way. see pg371 | [
"if",
"|a11",
"-",
"a22|",
">>",
"|a12",
"+",
"a21|",
"there",
"might",
"be",
"a",
"better",
"way",
".",
"see",
"pg371"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java#L33-L89 |
162,339 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java | EigenvalueSmall_F64.value2x2_fast | public void value2x2_fast( double a11 , double a12, double a21 , double a22 )
{
double left = (a11+a22)/2.0;
double inside = 4.0*a12*a21 + (a11-a22)*(a11-a22);
if( inside < 0 ) {
value0.real = value1.real = left;
value0.imaginary = Math.sqrt(-inside)/2.0;
value1.imaginary = -value0.imaginary;
} else {
double right = Math.sqrt(inside)/2.0;
value0.real = (left+right);
value1.real = (left-right);
value0.imaginary = value1.imaginary = 0.0;
}
} | java | public void value2x2_fast( double a11 , double a12, double a21 , double a22 )
{
double left = (a11+a22)/2.0;
double inside = 4.0*a12*a21 + (a11-a22)*(a11-a22);
if( inside < 0 ) {
value0.real = value1.real = left;
value0.imaginary = Math.sqrt(-inside)/2.0;
value1.imaginary = -value0.imaginary;
} else {
double right = Math.sqrt(inside)/2.0;
value0.real = (left+right);
value1.real = (left-right);
value0.imaginary = value1.imaginary = 0.0;
}
} | [
"public",
"void",
"value2x2_fast",
"(",
"double",
"a11",
",",
"double",
"a12",
",",
"double",
"a21",
",",
"double",
"a22",
")",
"{",
"double",
"left",
"=",
"(",
"a11",
"+",
"a22",
")",
"/",
"2.0",
";",
"double",
"inside",
"=",
"4.0",
"*",
"a12",
"*",
"a21",
"+",
"(",
"a11",
"-",
"a22",
")",
"*",
"(",
"a11",
"-",
"a22",
")",
";",
"if",
"(",
"inside",
"<",
"0",
")",
"{",
"value0",
".",
"real",
"=",
"value1",
".",
"real",
"=",
"left",
";",
"value0",
".",
"imaginary",
"=",
"Math",
".",
"sqrt",
"(",
"-",
"inside",
")",
"/",
"2.0",
";",
"value1",
".",
"imaginary",
"=",
"-",
"value0",
".",
"imaginary",
";",
"}",
"else",
"{",
"double",
"right",
"=",
"Math",
".",
"sqrt",
"(",
"inside",
")",
"/",
"2.0",
";",
"value0",
".",
"real",
"=",
"(",
"left",
"+",
"right",
")",
";",
"value1",
".",
"real",
"=",
"(",
"left",
"-",
"right",
")",
";",
"value0",
".",
"imaginary",
"=",
"value1",
".",
"imaginary",
"=",
"0.0",
";",
"}",
"}"
] | Computes the eigenvalues of a 2 by 2 matrix using a faster but more prone to errors method. This
is the typical method. | [
"Computes",
"the",
"eigenvalues",
"of",
"a",
"2",
"by",
"2",
"matrix",
"using",
"a",
"faster",
"but",
"more",
"prone",
"to",
"errors",
"method",
".",
"This",
"is",
"the",
"typical",
"method",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java#L95-L110 |
162,340 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java | EigenvalueSmall_F64.symm2x2_fast | public void symm2x2_fast( double a11 , double a12, double a22 )
{
// double p = (a11 - a22)*0.5;
// double r = Math.sqrt(p*p + a12*a12);
//
// value0.real = a22 + a12*a12/(r-p);
// value1.real = a22 - a12*a12/(r+p);
// }
//
// public void symm2x2_std( double a11 , double a12, double a22 )
// {
double left = (a11+a22)*0.5;
double b = (a11-a22)*0.5;
double right = Math.sqrt(b*b+a12*a12);
value0.real = left + right;
value1.real = left - right;
} | java | public void symm2x2_fast( double a11 , double a12, double a22 )
{
// double p = (a11 - a22)*0.5;
// double r = Math.sqrt(p*p + a12*a12);
//
// value0.real = a22 + a12*a12/(r-p);
// value1.real = a22 - a12*a12/(r+p);
// }
//
// public void symm2x2_std( double a11 , double a12, double a22 )
// {
double left = (a11+a22)*0.5;
double b = (a11-a22)*0.5;
double right = Math.sqrt(b*b+a12*a12);
value0.real = left + right;
value1.real = left - right;
} | [
"public",
"void",
"symm2x2_fast",
"(",
"double",
"a11",
",",
"double",
"a12",
",",
"double",
"a22",
")",
"{",
"// double p = (a11 - a22)*0.5;",
"// double r = Math.sqrt(p*p + a12*a12);",
"//",
"// value0.real = a22 + a12*a12/(r-p);",
"// value1.real = a22 - a12*a12/(r+p);",
"// }",
"//",
"// public void symm2x2_std( double a11 , double a12, double a22 )",
"// {",
"double",
"left",
"=",
"(",
"a11",
"+",
"a22",
")",
"*",
"0.5",
";",
"double",
"b",
"=",
"(",
"a11",
"-",
"a22",
")",
"*",
"0.5",
";",
"double",
"right",
"=",
"Math",
".",
"sqrt",
"(",
"b",
"*",
"b",
"+",
"a12",
"*",
"a12",
")",
";",
"value0",
".",
"real",
"=",
"left",
"+",
"right",
";",
"value1",
".",
"real",
"=",
"left",
"-",
"right",
";",
"}"
] | See page 385 of Fundamentals of Matrix Computations 2nd | [
"See",
"page",
"385",
"of",
"Fundamentals",
"of",
"Matrix",
"Computations",
"2nd"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/EigenvalueSmall_F64.java#L116-L132 |
162,341 | lessthanoptimal/ejml | main/ejml-experimental/benchmarks/src/org/ejml/dense/row/mult/BenchmarkMatrixMultAccessors.java | BenchmarkMatrixMultAccessors.wrapped | public static long wrapped(DMatrixRMaj a , DMatrixRMaj b , DMatrixRMaj c )
{
long timeBefore = System.currentTimeMillis();
double valA;
int indexCbase= 0;
int endOfKLoop = b.numRows*b.numCols;
for( int i = 0; i < a.numRows; i++ ) {
int indexA = i*a.numCols;
// need to assign dataC to a value initially
int indexB = 0;
int indexC = indexCbase;
int end = indexB + b.numCols;
valA = a.get(indexA++);
while( indexB < end ) {
c.set( indexC++ , valA*b.get(indexB++));
}
// now add to it
while( indexB != endOfKLoop ) { // k loop
indexC = indexCbase;
end = indexB + b.numCols;
valA = a.get(indexA++);
while( indexB < end ) { // j loop
c.plus( indexC++ , valA*b.get(indexB++));
}
}
indexCbase += c.numCols;
}
return System.currentTimeMillis() - timeBefore;
} | java | public static long wrapped(DMatrixRMaj a , DMatrixRMaj b , DMatrixRMaj c )
{
long timeBefore = System.currentTimeMillis();
double valA;
int indexCbase= 0;
int endOfKLoop = b.numRows*b.numCols;
for( int i = 0; i < a.numRows; i++ ) {
int indexA = i*a.numCols;
// need to assign dataC to a value initially
int indexB = 0;
int indexC = indexCbase;
int end = indexB + b.numCols;
valA = a.get(indexA++);
while( indexB < end ) {
c.set( indexC++ , valA*b.get(indexB++));
}
// now add to it
while( indexB != endOfKLoop ) { // k loop
indexC = indexCbase;
end = indexB + b.numCols;
valA = a.get(indexA++);
while( indexB < end ) { // j loop
c.plus( indexC++ , valA*b.get(indexB++));
}
}
indexCbase += c.numCols;
}
return System.currentTimeMillis() - timeBefore;
} | [
"public",
"static",
"long",
"wrapped",
"(",
"DMatrixRMaj",
"a",
",",
"DMatrixRMaj",
"b",
",",
"DMatrixRMaj",
"c",
")",
"{",
"long",
"timeBefore",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"double",
"valA",
";",
"int",
"indexCbase",
"=",
"0",
";",
"int",
"endOfKLoop",
"=",
"b",
".",
"numRows",
"*",
"b",
".",
"numCols",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"int",
"indexA",
"=",
"i",
"*",
"a",
".",
"numCols",
";",
"// need to assign dataC to a value initially",
"int",
"indexB",
"=",
"0",
";",
"int",
"indexC",
"=",
"indexCbase",
";",
"int",
"end",
"=",
"indexB",
"+",
"b",
".",
"numCols",
";",
"valA",
"=",
"a",
".",
"get",
"(",
"indexA",
"++",
")",
";",
"while",
"(",
"indexB",
"<",
"end",
")",
"{",
"c",
".",
"set",
"(",
"indexC",
"++",
",",
"valA",
"*",
"b",
".",
"get",
"(",
"indexB",
"++",
")",
")",
";",
"}",
"// now add to it",
"while",
"(",
"indexB",
"!=",
"endOfKLoop",
")",
"{",
"// k loop",
"indexC",
"=",
"indexCbase",
";",
"end",
"=",
"indexB",
"+",
"b",
".",
"numCols",
";",
"valA",
"=",
"a",
".",
"get",
"(",
"indexA",
"++",
")",
";",
"while",
"(",
"indexB",
"<",
"end",
")",
"{",
"// j loop",
"c",
".",
"plus",
"(",
"indexC",
"++",
",",
"valA",
"*",
"b",
".",
"get",
"(",
"indexB",
"++",
")",
")",
";",
"}",
"}",
"indexCbase",
"+=",
"c",
".",
"numCols",
";",
"}",
"return",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"timeBefore",
";",
"}"
] | Wrapper functions with no bounds checking are used to access matrix internals | [
"Wrapper",
"functions",
"with",
"no",
"bounds",
"checking",
"are",
"used",
"to",
"access",
"matrix",
"internals"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/benchmarks/src/org/ejml/dense/row/mult/BenchmarkMatrixMultAccessors.java#L83-L119 |
162,342 | lessthanoptimal/ejml | main/ejml-experimental/benchmarks/src/org/ejml/dense/row/mult/BenchmarkMatrixMultAccessors.java | BenchmarkMatrixMultAccessors.access2d | public static long access2d(DMatrixRMaj a , DMatrixRMaj b , DMatrixRMaj c )
{
long timeBefore = System.currentTimeMillis();
for( int i = 0; i < a.numRows; i++ ) {
for( int j = 0; j < b.numCols; j++ ) {
c.set(i,j,a.get(i,0)*b.get(0,j));
}
for( int k = 1; k < b.numRows; k++ ) {
for( int j = 0; j < b.numCols; j++ ) {
// c.set(i,j, c.get(i,j) + a.get(i,k)*b.get(k,j));
c.data[i*b.numCols+j] +=a.get(i,k)*b.get(k,j);
}
}
}
return System.currentTimeMillis() - timeBefore;
} | java | public static long access2d(DMatrixRMaj a , DMatrixRMaj b , DMatrixRMaj c )
{
long timeBefore = System.currentTimeMillis();
for( int i = 0; i < a.numRows; i++ ) {
for( int j = 0; j < b.numCols; j++ ) {
c.set(i,j,a.get(i,0)*b.get(0,j));
}
for( int k = 1; k < b.numRows; k++ ) {
for( int j = 0; j < b.numCols; j++ ) {
// c.set(i,j, c.get(i,j) + a.get(i,k)*b.get(k,j));
c.data[i*b.numCols+j] +=a.get(i,k)*b.get(k,j);
}
}
}
return System.currentTimeMillis() - timeBefore;
} | [
"public",
"static",
"long",
"access2d",
"(",
"DMatrixRMaj",
"a",
",",
"DMatrixRMaj",
"b",
",",
"DMatrixRMaj",
"c",
")",
"{",
"long",
"timeBefore",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"b",
".",
"numCols",
";",
"j",
"++",
")",
"{",
"c",
".",
"set",
"(",
"i",
",",
"j",
",",
"a",
".",
"get",
"(",
"i",
",",
"0",
")",
"*",
"b",
".",
"get",
"(",
"0",
",",
"j",
")",
")",
";",
"}",
"for",
"(",
"int",
"k",
"=",
"1",
";",
"k",
"<",
"b",
".",
"numRows",
";",
"k",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"b",
".",
"numCols",
";",
"j",
"++",
")",
"{",
"// c.set(i,j, c.get(i,j) + a.get(i,k)*b.get(k,j));",
"c",
".",
"data",
"[",
"i",
"*",
"b",
".",
"numCols",
"+",
"j",
"]",
"+=",
"a",
".",
"get",
"(",
"i",
",",
"k",
")",
"*",
"b",
".",
"get",
"(",
"k",
",",
"j",
")",
";",
"}",
"}",
"}",
"return",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"timeBefore",
";",
"}"
] | Only sets and gets that are by row and column are used. | [
"Only",
"sets",
"and",
"gets",
"that",
"are",
"by",
"row",
"and",
"column",
"are",
"used",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/benchmarks/src/org/ejml/dense/row/mult/BenchmarkMatrixMultAccessors.java#L124-L143 |
162,343 | lessthanoptimal/ejml | main/ejml-core/src/org/ejml/FancyPrint.java | FancyPrint.p | public String p(double value ) {
return UtilEjml.fancyString(value,format,false,length,significant);
} | java | public String p(double value ) {
return UtilEjml.fancyString(value,format,false,length,significant);
} | [
"public",
"String",
"p",
"(",
"double",
"value",
")",
"{",
"return",
"UtilEjml",
".",
"fancyString",
"(",
"value",
",",
"format",
",",
"false",
",",
"length",
",",
"significant",
")",
";",
"}"
] | Fancy print without a space added to positive numbers | [
"Fancy",
"print",
"without",
"a",
"space",
"added",
"to",
"positive",
"numbers"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/FancyPrint.java#L61-L63 |
162,344 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQrAlgorithm_DDRM.java | SymmetricQrAlgorithm_DDRM.process | public boolean process( int sideLength,
double diag[] ,
double off[] ,
double eigenvalues[] ) {
if( diag != null )
helper.init(diag,off,sideLength);
if( Q == null )
Q = CommonOps_DDRM.identity(helper.N);
helper.setQ(Q);
this.followingScript = true;
this.eigenvalues = eigenvalues;
this.fastEigenvalues = false;
return _process();
} | java | public boolean process( int sideLength,
double diag[] ,
double off[] ,
double eigenvalues[] ) {
if( diag != null )
helper.init(diag,off,sideLength);
if( Q == null )
Q = CommonOps_DDRM.identity(helper.N);
helper.setQ(Q);
this.followingScript = true;
this.eigenvalues = eigenvalues;
this.fastEigenvalues = false;
return _process();
} | [
"public",
"boolean",
"process",
"(",
"int",
"sideLength",
",",
"double",
"diag",
"[",
"]",
",",
"double",
"off",
"[",
"]",
",",
"double",
"eigenvalues",
"[",
"]",
")",
"{",
"if",
"(",
"diag",
"!=",
"null",
")",
"helper",
".",
"init",
"(",
"diag",
",",
"off",
",",
"sideLength",
")",
";",
"if",
"(",
"Q",
"==",
"null",
")",
"Q",
"=",
"CommonOps_DDRM",
".",
"identity",
"(",
"helper",
".",
"N",
")",
";",
"helper",
".",
"setQ",
"(",
"Q",
")",
";",
"this",
".",
"followingScript",
"=",
"true",
";",
"this",
".",
"eigenvalues",
"=",
"eigenvalues",
";",
"this",
".",
"fastEigenvalues",
"=",
"false",
";",
"return",
"_process",
"(",
")",
";",
"}"
] | Computes the eigenvalue of the provided tridiagonal matrix. Note that only the upper portion
needs to be tridiagonal. The bottom diagonal is assumed to be the same as the top.
@param sideLength Number of rows and columns in the input matrix.
@param diag Diagonal elements from tridiagonal matrix. Modified.
@param off Off diagonal elements from tridiagonal matrix. Modified.
@return true if it succeeds and false if it fails. | [
"Computes",
"the",
"eigenvalue",
"of",
"the",
"provided",
"tridiagonal",
"matrix",
".",
"Note",
"that",
"only",
"the",
"upper",
"portion",
"needs",
"to",
"be",
"tridiagonal",
".",
"The",
"bottom",
"diagonal",
"is",
"assumed",
"to",
"be",
"the",
"same",
"as",
"the",
"top",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQrAlgorithm_DDRM.java#L111-L126 |
162,345 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQrAlgorithm_DDRM.java | SymmetricQrAlgorithm_DDRM.performStep | public void performStep() {
// check for zeros
for( int i = helper.x2-1; i >= helper.x1; i-- ) {
if( helper.isZero(i) ) {
helper.splits[helper.numSplits++] = i;
helper.x1 = i+1;
return;
}
}
double lambda;
if( followingScript ) {
if( helper.steps > 10 ) {
followingScript = false;
return;
} else {
// Using the true eigenvalues will in general lead to the fastest convergence
// typically takes 1 or 2 steps
lambda = eigenvalues[helper.x2];
}
} else {
// the current eigenvalue isn't working so try something else
lambda = helper.computeShift();
}
// similar transforms
helper.performImplicitSingleStep(lambda,false);
} | java | public void performStep() {
// check for zeros
for( int i = helper.x2-1; i >= helper.x1; i-- ) {
if( helper.isZero(i) ) {
helper.splits[helper.numSplits++] = i;
helper.x1 = i+1;
return;
}
}
double lambda;
if( followingScript ) {
if( helper.steps > 10 ) {
followingScript = false;
return;
} else {
// Using the true eigenvalues will in general lead to the fastest convergence
// typically takes 1 or 2 steps
lambda = eigenvalues[helper.x2];
}
} else {
// the current eigenvalue isn't working so try something else
lambda = helper.computeShift();
}
// similar transforms
helper.performImplicitSingleStep(lambda,false);
} | [
"public",
"void",
"performStep",
"(",
")",
"{",
"// check for zeros",
"for",
"(",
"int",
"i",
"=",
"helper",
".",
"x2",
"-",
"1",
";",
"i",
">=",
"helper",
".",
"x1",
";",
"i",
"--",
")",
"{",
"if",
"(",
"helper",
".",
"isZero",
"(",
"i",
")",
")",
"{",
"helper",
".",
"splits",
"[",
"helper",
".",
"numSplits",
"++",
"]",
"=",
"i",
";",
"helper",
".",
"x1",
"=",
"i",
"+",
"1",
";",
"return",
";",
"}",
"}",
"double",
"lambda",
";",
"if",
"(",
"followingScript",
")",
"{",
"if",
"(",
"helper",
".",
"steps",
">",
"10",
")",
"{",
"followingScript",
"=",
"false",
";",
"return",
";",
"}",
"else",
"{",
"// Using the true eigenvalues will in general lead to the fastest convergence",
"// typically takes 1 or 2 steps",
"lambda",
"=",
"eigenvalues",
"[",
"helper",
".",
"x2",
"]",
";",
"}",
"}",
"else",
"{",
"// the current eigenvalue isn't working so try something else",
"lambda",
"=",
"helper",
".",
"computeShift",
"(",
")",
";",
"}",
"// similar transforms",
"helper",
".",
"performImplicitSingleStep",
"(",
"lambda",
",",
"false",
")",
";",
"}"
] | First looks for zeros and then performs the implicit single step in the QR Algorithm. | [
"First",
"looks",
"for",
"zeros",
"and",
"then",
"performs",
"the",
"implicit",
"single",
"step",
"in",
"the",
"QR",
"Algorithm",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQrAlgorithm_DDRM.java#L177-L205 |
162,346 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/misc/TransposeAlgs_DDRM.java | TransposeAlgs_DDRM.block | public static void block(DMatrix1Row A , DMatrix1Row A_tran ,
final int blockLength )
{
for( int i = 0; i < A.numRows; i += blockLength ) {
int blockHeight = Math.min( blockLength , A.numRows - i);
int indexSrc = i*A.numCols;
int indexDst = i;
for( int j = 0; j < A.numCols; j += blockLength ) {
int blockWidth = Math.min( blockLength , A.numCols - j);
// int indexSrc = i*A.numCols + j;
// int indexDst = j*A_tran.numCols + i;
int indexSrcEnd = indexSrc + blockWidth;
// for( int l = 0; l < blockWidth; l++ , indexSrc++ ) {
for( ; indexSrc < indexSrcEnd; indexSrc++ ) {
int rowSrc = indexSrc;
int rowDst = indexDst;
int end = rowDst + blockHeight;
// for( int k = 0; k < blockHeight; k++ , rowSrc += A.numCols ) {
for( ; rowDst < end; rowSrc += A.numCols ) {
// faster to write in sequence than to read in sequence
A_tran.data[ rowDst++ ] = A.data[ rowSrc ];
}
indexDst += A_tran.numCols;
}
}
}
} | java | public static void block(DMatrix1Row A , DMatrix1Row A_tran ,
final int blockLength )
{
for( int i = 0; i < A.numRows; i += blockLength ) {
int blockHeight = Math.min( blockLength , A.numRows - i);
int indexSrc = i*A.numCols;
int indexDst = i;
for( int j = 0; j < A.numCols; j += blockLength ) {
int blockWidth = Math.min( blockLength , A.numCols - j);
// int indexSrc = i*A.numCols + j;
// int indexDst = j*A_tran.numCols + i;
int indexSrcEnd = indexSrc + blockWidth;
// for( int l = 0; l < blockWidth; l++ , indexSrc++ ) {
for( ; indexSrc < indexSrcEnd; indexSrc++ ) {
int rowSrc = indexSrc;
int rowDst = indexDst;
int end = rowDst + blockHeight;
// for( int k = 0; k < blockHeight; k++ , rowSrc += A.numCols ) {
for( ; rowDst < end; rowSrc += A.numCols ) {
// faster to write in sequence than to read in sequence
A_tran.data[ rowDst++ ] = A.data[ rowSrc ];
}
indexDst += A_tran.numCols;
}
}
}
} | [
"public",
"static",
"void",
"block",
"(",
"DMatrix1Row",
"A",
",",
"DMatrix1Row",
"A_tran",
",",
"final",
"int",
"blockLength",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"numRows",
";",
"i",
"+=",
"blockLength",
")",
"{",
"int",
"blockHeight",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numRows",
"-",
"i",
")",
";",
"int",
"indexSrc",
"=",
"i",
"*",
"A",
".",
"numCols",
";",
"int",
"indexDst",
"=",
"i",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"A",
".",
"numCols",
";",
"j",
"+=",
"blockLength",
")",
"{",
"int",
"blockWidth",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numCols",
"-",
"j",
")",
";",
"// int indexSrc = i*A.numCols + j;",
"// int indexDst = j*A_tran.numCols + i;",
"int",
"indexSrcEnd",
"=",
"indexSrc",
"+",
"blockWidth",
";",
"// for( int l = 0; l < blockWidth; l++ , indexSrc++ ) {",
"for",
"(",
";",
"indexSrc",
"<",
"indexSrcEnd",
";",
"indexSrc",
"++",
")",
"{",
"int",
"rowSrc",
"=",
"indexSrc",
";",
"int",
"rowDst",
"=",
"indexDst",
";",
"int",
"end",
"=",
"rowDst",
"+",
"blockHeight",
";",
"// for( int k = 0; k < blockHeight; k++ , rowSrc += A.numCols ) {",
"for",
"(",
";",
"rowDst",
"<",
"end",
";",
"rowSrc",
"+=",
"A",
".",
"numCols",
")",
"{",
"// faster to write in sequence than to read in sequence",
"A_tran",
".",
"data",
"[",
"rowDst",
"++",
"]",
"=",
"A",
".",
"data",
"[",
"rowSrc",
"]",
";",
"}",
"indexDst",
"+=",
"A_tran",
".",
"numCols",
";",
"}",
"}",
"}",
"}"
] | Performs a transpose across block sub-matrices. Reduces
the number of cache misses on larger matrices.
*NOTE* If this is beneficial is highly dependent on the computer it is run on. e.g:
- Q6600 Almost twice as fast as standard.
- Pentium-M Same speed and some times a bit slower than standard.
@param A Original matrix. Not modified.
@param A_tran Transposed matrix. Modified.
@param blockLength Length of a block. | [
"Performs",
"a",
"transpose",
"across",
"block",
"sub",
"-",
"matrices",
".",
"Reduces",
"the",
"number",
"of",
"cache",
"misses",
"on",
"larger",
"matrices",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/misc/TransposeAlgs_DDRM.java#L65-L95 |
162,347 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/generic/GenericMatrixOps_F64.java | GenericMatrixOps_F64.isIdentity | public static boolean isIdentity(DMatrix a , double tol )
{
for( int i = 0; i < a.getNumRows(); i++ ) {
for( int j = 0; j < a.getNumCols(); j++ ) {
if( i == j ) {
if( Math.abs(a.get(i,j)-1.0) > tol )
return false;
} else {
if( Math.abs(a.get(i,j)) > tol )
return false;
}
}
}
return true;
} | java | public static boolean isIdentity(DMatrix a , double tol )
{
for( int i = 0; i < a.getNumRows(); i++ ) {
for( int j = 0; j < a.getNumCols(); j++ ) {
if( i == j ) {
if( Math.abs(a.get(i,j)-1.0) > tol )
return false;
} else {
if( Math.abs(a.get(i,j)) > tol )
return false;
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"isIdentity",
"(",
"DMatrix",
"a",
",",
"double",
"tol",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"getNumRows",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"a",
".",
"getNumCols",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"i",
"==",
"j",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"a",
".",
"get",
"(",
"i",
",",
"j",
")",
"-",
"1.0",
")",
">",
"tol",
")",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"a",
".",
"get",
"(",
"i",
",",
"j",
")",
")",
">",
"tol",
")",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns true if the provided matrix is has a value of 1 along the diagonal
elements and zero along all the other elements.
@param a Matrix being inspected.
@param tol How close to zero or one each element needs to be.
@return If it is within tolerance to an identity matrix. | [
"Returns",
"true",
"if",
"the",
"provided",
"matrix",
"is",
"has",
"a",
"value",
"of",
"1",
"along",
"the",
"diagonal",
"elements",
"and",
"zero",
"along",
"all",
"the",
"other",
"elements",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/generic/GenericMatrixOps_F64.java#L63-L77 |
162,348 | lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/decomposition/qr/QrHelperFunctions_DSCC.java | QrHelperFunctions_DSCC.computeHouseholder | public static double computeHouseholder(double []x , int xStart , int xEnd , double max , DScalar gamma ) {
double tau = 0;
for (int i = xStart; i < xEnd ; i++) {
double val = x[i] /= max;
tau += val*val;
}
tau = Math.sqrt(tau);
if( x[xStart] < 0 ) {
tau = -tau;
}
double u_0 = x[xStart] + tau;
gamma.value = u_0/tau;
x[xStart] = 1;
for (int i = xStart+1; i < xEnd ; i++) {
x[i] /= u_0;
}
return -tau*max;
} | java | public static double computeHouseholder(double []x , int xStart , int xEnd , double max , DScalar gamma ) {
double tau = 0;
for (int i = xStart; i < xEnd ; i++) {
double val = x[i] /= max;
tau += val*val;
}
tau = Math.sqrt(tau);
if( x[xStart] < 0 ) {
tau = -tau;
}
double u_0 = x[xStart] + tau;
gamma.value = u_0/tau;
x[xStart] = 1;
for (int i = xStart+1; i < xEnd ; i++) {
x[i] /= u_0;
}
return -tau*max;
} | [
"public",
"static",
"double",
"computeHouseholder",
"(",
"double",
"[",
"]",
"x",
",",
"int",
"xStart",
",",
"int",
"xEnd",
",",
"double",
"max",
",",
"DScalar",
"gamma",
")",
"{",
"double",
"tau",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"xStart",
";",
"i",
"<",
"xEnd",
";",
"i",
"++",
")",
"{",
"double",
"val",
"=",
"x",
"[",
"i",
"]",
"/=",
"max",
";",
"tau",
"+=",
"val",
"*",
"val",
";",
"}",
"tau",
"=",
"Math",
".",
"sqrt",
"(",
"tau",
")",
";",
"if",
"(",
"x",
"[",
"xStart",
"]",
"<",
"0",
")",
"{",
"tau",
"=",
"-",
"tau",
";",
"}",
"double",
"u_0",
"=",
"x",
"[",
"xStart",
"]",
"+",
"tau",
";",
"gamma",
".",
"value",
"=",
"u_0",
"/",
"tau",
";",
"x",
"[",
"xStart",
"]",
"=",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"xStart",
"+",
"1",
";",
"i",
"<",
"xEnd",
";",
"i",
"++",
")",
"{",
"x",
"[",
"i",
"]",
"/=",
"u_0",
";",
"}",
"return",
"-",
"tau",
"*",
"max",
";",
"}"
] | Creates a householder reflection.
(I-gamma*v*v')*x = tau*e1
<p>NOTE: Same as cs_house in csparse</p>
@param x (Input) Vector x (Output) Vector v. Modified.
@param xStart First index in X that is to be processed
@param xEnd Last + 1 index in x that is to be processed.
@param gamma (Output) Storage for computed gamma
@return variable tau | [
"Creates",
"a",
"householder",
"reflection",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/decomposition/qr/QrHelperFunctions_DSCC.java#L110-L128 |
162,349 | lessthanoptimal/ejml | main/ejml-experimental/benchmarks/src/org/ejml/BenchmarkInliningGetSet.java | BenchmarkInliningGetSet.get1D | public static long get1D(DMatrixRMaj A , int n ) {
long before = System.currentTimeMillis();
double total = 0;
for( int iter = 0; iter < n; iter++ ) {
int index = 0;
for( int i = 0; i < A.numRows; i++ ) {
int end = index+A.numCols;
while( index != end ) {
total += A.get(index++);
}
}
}
long after = System.currentTimeMillis();
// print to ensure that ensure that an overly smart compiler does not optimize out
// the whole function and to show that both produce the same results.
System.out.println(total);
return after-before;
} | java | public static long get1D(DMatrixRMaj A , int n ) {
long before = System.currentTimeMillis();
double total = 0;
for( int iter = 0; iter < n; iter++ ) {
int index = 0;
for( int i = 0; i < A.numRows; i++ ) {
int end = index+A.numCols;
while( index != end ) {
total += A.get(index++);
}
}
}
long after = System.currentTimeMillis();
// print to ensure that ensure that an overly smart compiler does not optimize out
// the whole function and to show that both produce the same results.
System.out.println(total);
return after-before;
} | [
"public",
"static",
"long",
"get1D",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"n",
")",
"{",
"long",
"before",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"double",
"total",
"=",
"0",
";",
"for",
"(",
"int",
"iter",
"=",
"0",
";",
"iter",
"<",
"n",
";",
"iter",
"++",
")",
"{",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"int",
"end",
"=",
"index",
"+",
"A",
".",
"numCols",
";",
"while",
"(",
"index",
"!=",
"end",
")",
"{",
"total",
"+=",
"A",
".",
"get",
"(",
"index",
"++",
")",
";",
"}",
"}",
"}",
"long",
"after",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"// print to ensure that ensure that an overly smart compiler does not optimize out",
"// the whole function and to show that both produce the same results.",
"System",
".",
"out",
".",
"println",
"(",
"total",
")",
";",
"return",
"after",
"-",
"before",
";",
"}"
] | Get by index is used here. | [
"Get",
"by",
"index",
"is",
"used",
"here",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/benchmarks/src/org/ejml/BenchmarkInliningGetSet.java#L91-L115 |
162,350 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java | QRDecompositionHouseholder_DDRB.initializeQ | public static DMatrixRBlock initializeQ(DMatrixRBlock Q,
int numRows , int numCols , int blockLength ,
boolean compact) {
int minLength = Math.min(numRows,numCols);
if( compact ) {
if( Q == null ) {
Q = new DMatrixRBlock(numRows,minLength,blockLength);
MatrixOps_DDRB.setIdentity(Q);
} else {
if( Q.numRows != numRows || Q.numCols != minLength ) {
throw new IllegalArgumentException("Unexpected matrix dimension. Found "+Q.numRows+" "+Q.numCols);
} else {
MatrixOps_DDRB.setIdentity(Q);
}
}
} else {
if( Q == null ) {
Q = new DMatrixRBlock(numRows,numRows,blockLength);
MatrixOps_DDRB.setIdentity(Q);
} else {
if( Q.numRows != numRows || Q.numCols != numRows ) {
throw new IllegalArgumentException("Unexpected matrix dimension. Found "+Q.numRows+" "+Q.numCols);
} else {
MatrixOps_DDRB.setIdentity(Q);
}
}
}
return Q;
} | java | public static DMatrixRBlock initializeQ(DMatrixRBlock Q,
int numRows , int numCols , int blockLength ,
boolean compact) {
int minLength = Math.min(numRows,numCols);
if( compact ) {
if( Q == null ) {
Q = new DMatrixRBlock(numRows,minLength,blockLength);
MatrixOps_DDRB.setIdentity(Q);
} else {
if( Q.numRows != numRows || Q.numCols != minLength ) {
throw new IllegalArgumentException("Unexpected matrix dimension. Found "+Q.numRows+" "+Q.numCols);
} else {
MatrixOps_DDRB.setIdentity(Q);
}
}
} else {
if( Q == null ) {
Q = new DMatrixRBlock(numRows,numRows,blockLength);
MatrixOps_DDRB.setIdentity(Q);
} else {
if( Q.numRows != numRows || Q.numCols != numRows ) {
throw new IllegalArgumentException("Unexpected matrix dimension. Found "+Q.numRows+" "+Q.numCols);
} else {
MatrixOps_DDRB.setIdentity(Q);
}
}
}
return Q;
} | [
"public",
"static",
"DMatrixRBlock",
"initializeQ",
"(",
"DMatrixRBlock",
"Q",
",",
"int",
"numRows",
",",
"int",
"numCols",
",",
"int",
"blockLength",
",",
"boolean",
"compact",
")",
"{",
"int",
"minLength",
"=",
"Math",
".",
"min",
"(",
"numRows",
",",
"numCols",
")",
";",
"if",
"(",
"compact",
")",
"{",
"if",
"(",
"Q",
"==",
"null",
")",
"{",
"Q",
"=",
"new",
"DMatrixRBlock",
"(",
"numRows",
",",
"minLength",
",",
"blockLength",
")",
";",
"MatrixOps_DDRB",
".",
"setIdentity",
"(",
"Q",
")",
";",
"}",
"else",
"{",
"if",
"(",
"Q",
".",
"numRows",
"!=",
"numRows",
"||",
"Q",
".",
"numCols",
"!=",
"minLength",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected matrix dimension. Found \"",
"+",
"Q",
".",
"numRows",
"+",
"\" \"",
"+",
"Q",
".",
"numCols",
")",
";",
"}",
"else",
"{",
"MatrixOps_DDRB",
".",
"setIdentity",
"(",
"Q",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"Q",
"==",
"null",
")",
"{",
"Q",
"=",
"new",
"DMatrixRBlock",
"(",
"numRows",
",",
"numRows",
",",
"blockLength",
")",
";",
"MatrixOps_DDRB",
".",
"setIdentity",
"(",
"Q",
")",
";",
"}",
"else",
"{",
"if",
"(",
"Q",
".",
"numRows",
"!=",
"numRows",
"||",
"Q",
".",
"numCols",
"!=",
"numRows",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected matrix dimension. Found \"",
"+",
"Q",
".",
"numRows",
"+",
"\" \"",
"+",
"Q",
".",
"numCols",
")",
";",
"}",
"else",
"{",
"MatrixOps_DDRB",
".",
"setIdentity",
"(",
"Q",
")",
";",
"}",
"}",
"}",
"return",
"Q",
";",
"}"
] | Sanity checks the input or declares a new matrix. Return matrix is an identity matrix. | [
"Sanity",
"checks",
"the",
"input",
"or",
"declares",
"a",
"new",
"matrix",
".",
"Return",
"matrix",
"is",
"an",
"identity",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java#L124-L152 |
162,351 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java | QRDecompositionHouseholder_DDRB.setup | private void setup(DMatrixRBlock orig) {
blockLength = orig.blockLength;
dataW.blockLength = blockLength;
dataWTA.blockLength = blockLength;
this.dataA = orig;
A.original = dataA;
int l = Math.min(blockLength,orig.numCols);
dataW.reshape(orig.numRows,l,false);
dataWTA.reshape(l,orig.numRows,false);
Y.original = orig;
Y.row1 = W.row1 = orig.numRows;
if( temp.length < blockLength )
temp = new double[blockLength];
if( gammas.length < orig.numCols )
gammas = new double[ orig.numCols ];
if( saveW ) {
dataW.reshape(orig.numRows,orig.numCols,false);
}
} | java | private void setup(DMatrixRBlock orig) {
blockLength = orig.blockLength;
dataW.blockLength = blockLength;
dataWTA.blockLength = blockLength;
this.dataA = orig;
A.original = dataA;
int l = Math.min(blockLength,orig.numCols);
dataW.reshape(orig.numRows,l,false);
dataWTA.reshape(l,orig.numRows,false);
Y.original = orig;
Y.row1 = W.row1 = orig.numRows;
if( temp.length < blockLength )
temp = new double[blockLength];
if( gammas.length < orig.numCols )
gammas = new double[ orig.numCols ];
if( saveW ) {
dataW.reshape(orig.numRows,orig.numCols,false);
}
} | [
"private",
"void",
"setup",
"(",
"DMatrixRBlock",
"orig",
")",
"{",
"blockLength",
"=",
"orig",
".",
"blockLength",
";",
"dataW",
".",
"blockLength",
"=",
"blockLength",
";",
"dataWTA",
".",
"blockLength",
"=",
"blockLength",
";",
"this",
".",
"dataA",
"=",
"orig",
";",
"A",
".",
"original",
"=",
"dataA",
";",
"int",
"l",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"orig",
".",
"numCols",
")",
";",
"dataW",
".",
"reshape",
"(",
"orig",
".",
"numRows",
",",
"l",
",",
"false",
")",
";",
"dataWTA",
".",
"reshape",
"(",
"l",
",",
"orig",
".",
"numRows",
",",
"false",
")",
";",
"Y",
".",
"original",
"=",
"orig",
";",
"Y",
".",
"row1",
"=",
"W",
".",
"row1",
"=",
"orig",
".",
"numRows",
";",
"if",
"(",
"temp",
".",
"length",
"<",
"blockLength",
")",
"temp",
"=",
"new",
"double",
"[",
"blockLength",
"]",
";",
"if",
"(",
"gammas",
".",
"length",
"<",
"orig",
".",
"numCols",
")",
"gammas",
"=",
"new",
"double",
"[",
"orig",
".",
"numCols",
"]",
";",
"if",
"(",
"saveW",
")",
"{",
"dataW",
".",
"reshape",
"(",
"orig",
".",
"numRows",
",",
"orig",
".",
"numCols",
",",
"false",
")",
";",
"}",
"}"
] | Adjust submatrices and helper data structures for the input matrix. Must be called
before the decomposition can be computed.
@param orig | [
"Adjust",
"submatrices",
"and",
"helper",
"data",
"structures",
"for",
"the",
"input",
"matrix",
".",
"Must",
"be",
"called",
"before",
"the",
"decomposition",
"can",
"be",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java#L326-L347 |
162,352 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java | QRDecompositionHouseholder_DDRB.setW | private void setW() {
if( saveW ) {
W.col0 = Y.col0;
W.col1 = Y.col1;
W.row0 = Y.row0;
W.row1 = Y.row1;
} else {
W.col1 = Y.col1 - Y.col0;
W.row0 = Y.row0;
}
} | java | private void setW() {
if( saveW ) {
W.col0 = Y.col0;
W.col1 = Y.col1;
W.row0 = Y.row0;
W.row1 = Y.row1;
} else {
W.col1 = Y.col1 - Y.col0;
W.row0 = Y.row0;
}
} | [
"private",
"void",
"setW",
"(",
")",
"{",
"if",
"(",
"saveW",
")",
"{",
"W",
".",
"col0",
"=",
"Y",
".",
"col0",
";",
"W",
".",
"col1",
"=",
"Y",
".",
"col1",
";",
"W",
".",
"row0",
"=",
"Y",
".",
"row0",
";",
"W",
".",
"row1",
"=",
"Y",
".",
"row1",
";",
"}",
"else",
"{",
"W",
".",
"col1",
"=",
"Y",
".",
"col1",
"-",
"Y",
".",
"col0",
";",
"W",
".",
"row0",
"=",
"Y",
".",
"row0",
";",
"}",
"}"
] | Sets the submatrix of W up give Y is already configured and if it is being cached or not. | [
"Sets",
"the",
"submatrix",
"of",
"W",
"up",
"give",
"Y",
"is",
"already",
"configured",
"and",
"if",
"it",
"is",
"being",
"cached",
"or",
"not",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java#L385-L395 |
162,353 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java | LinearSolverChol_ZDRM.solveInternalL | private void solveInternalL() {
// This takes advantage of the diagonal elements always being real numbers
// solve L*y=b storing y in x
TriangularSolver_ZDRM.solveL_diagReal(t, vv, n);
// solve L^T*x=y
TriangularSolver_ZDRM.solveConjTranL_diagReal(t, vv, n);
} | java | private void solveInternalL() {
// This takes advantage of the diagonal elements always being real numbers
// solve L*y=b storing y in x
TriangularSolver_ZDRM.solveL_diagReal(t, vv, n);
// solve L^T*x=y
TriangularSolver_ZDRM.solveConjTranL_diagReal(t, vv, n);
} | [
"private",
"void",
"solveInternalL",
"(",
")",
"{",
"// This takes advantage of the diagonal elements always being real numbers",
"// solve L*y=b storing y in x",
"TriangularSolver_ZDRM",
".",
"solveL_diagReal",
"(",
"t",
",",
"vv",
",",
"n",
")",
";",
"// solve L^T*x=y",
"TriangularSolver_ZDRM",
".",
"solveConjTranL_diagReal",
"(",
"t",
",",
"vv",
",",
"n",
")",
";",
"}"
] | Used internally to find the solution to a single column vector. | [
"Used",
"internally",
"to",
"find",
"the",
"solution",
"to",
"a",
"single",
"column",
"vector",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java#L114-L122 |
162,354 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java | LinearSolverChol_ZDRM.invert | @Override
public void invert( ZMatrixRMaj inv ) {
if( inv.numRows != n || inv.numCols != n ) {
throw new RuntimeException("Unexpected matrix dimension");
}
if( inv.data == t ) {
throw new IllegalArgumentException("Passing in the same matrix that was decomposed.");
}
if(decomposer.isLower()) {
setToInverseL(inv.data);
} else {
throw new RuntimeException("Implement");
}
} | java | @Override
public void invert( ZMatrixRMaj inv ) {
if( inv.numRows != n || inv.numCols != n ) {
throw new RuntimeException("Unexpected matrix dimension");
}
if( inv.data == t ) {
throw new IllegalArgumentException("Passing in the same matrix that was decomposed.");
}
if(decomposer.isLower()) {
setToInverseL(inv.data);
} else {
throw new RuntimeException("Implement");
}
} | [
"@",
"Override",
"public",
"void",
"invert",
"(",
"ZMatrixRMaj",
"inv",
")",
"{",
"if",
"(",
"inv",
".",
"numRows",
"!=",
"n",
"||",
"inv",
".",
"numCols",
"!=",
"n",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected matrix dimension\"",
")",
";",
"}",
"if",
"(",
"inv",
".",
"data",
"==",
"t",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Passing in the same matrix that was decomposed.\"",
")",
";",
"}",
"if",
"(",
"decomposer",
".",
"isLower",
"(",
")",
")",
"{",
"setToInverseL",
"(",
"inv",
".",
"data",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Implement\"",
")",
";",
"}",
"}"
] | Sets the matrix 'inv' equal to the inverse of the matrix that was decomposed.
@param inv Where the value of the inverse will be stored. Modified. | [
"Sets",
"the",
"matrix",
"inv",
"equal",
"to",
"the",
"inverse",
"of",
"the",
"matrix",
"that",
"was",
"decomposed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java#L129-L143 |
162,355 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.declareInternalData | public void declareInternalData(int maxRows, int maxCols) {
this.maxRows = maxRows;
this.maxCols = maxCols;
U_tran = new DMatrixRMaj(maxRows,maxRows);
Qm = new DMatrixRMaj(maxRows,maxRows);
r_row = new double[ maxCols ];
} | java | public void declareInternalData(int maxRows, int maxCols) {
this.maxRows = maxRows;
this.maxCols = maxCols;
U_tran = new DMatrixRMaj(maxRows,maxRows);
Qm = new DMatrixRMaj(maxRows,maxRows);
r_row = new double[ maxCols ];
} | [
"public",
"void",
"declareInternalData",
"(",
"int",
"maxRows",
",",
"int",
"maxCols",
")",
"{",
"this",
".",
"maxRows",
"=",
"maxRows",
";",
"this",
".",
"maxCols",
"=",
"maxCols",
";",
"U_tran",
"=",
"new",
"DMatrixRMaj",
"(",
"maxRows",
",",
"maxRows",
")",
";",
"Qm",
"=",
"new",
"DMatrixRMaj",
"(",
"maxRows",
",",
"maxRows",
")",
";",
"r_row",
"=",
"new",
"double",
"[",
"maxCols",
"]",
";",
"}"
] | Declares the internal data structures so that it can process matrices up to the specified size.
@param maxRows
@param maxCols | [
"Declares",
"the",
"internal",
"data",
"structures",
"so",
"that",
"it",
"can",
"process",
"matrices",
"up",
"to",
"the",
"specified",
"size",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L114-L122 |
162,356 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.setQR | private void setQR(DMatrixRMaj Q , DMatrixRMaj R , int growRows ) {
if( Q.numRows != Q.numCols ) {
throw new IllegalArgumentException("Q should be square.");
}
this.Q = Q;
this.R = R;
m = Q.numRows;
n = R.numCols;
if( m+growRows > maxRows || n > maxCols ) {
if( autoGrow ) {
declareInternalData(m+growRows,n);
} else {
throw new IllegalArgumentException("Autogrow has been set to false and the maximum number of rows" +
" or columns has been exceeded.");
}
}
} | java | private void setQR(DMatrixRMaj Q , DMatrixRMaj R , int growRows ) {
if( Q.numRows != Q.numCols ) {
throw new IllegalArgumentException("Q should be square.");
}
this.Q = Q;
this.R = R;
m = Q.numRows;
n = R.numCols;
if( m+growRows > maxRows || n > maxCols ) {
if( autoGrow ) {
declareInternalData(m+growRows,n);
} else {
throw new IllegalArgumentException("Autogrow has been set to false and the maximum number of rows" +
" or columns has been exceeded.");
}
}
} | [
"private",
"void",
"setQR",
"(",
"DMatrixRMaj",
"Q",
",",
"DMatrixRMaj",
"R",
",",
"int",
"growRows",
")",
"{",
"if",
"(",
"Q",
".",
"numRows",
"!=",
"Q",
".",
"numCols",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Q should be square.\"",
")",
";",
"}",
"this",
".",
"Q",
"=",
"Q",
";",
"this",
".",
"R",
"=",
"R",
";",
"m",
"=",
"Q",
".",
"numRows",
";",
"n",
"=",
"R",
".",
"numCols",
";",
"if",
"(",
"m",
"+",
"growRows",
">",
"maxRows",
"||",
"n",
">",
"maxCols",
")",
"{",
"if",
"(",
"autoGrow",
")",
"{",
"declareInternalData",
"(",
"m",
"+",
"growRows",
",",
"n",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Autogrow has been set to false and the maximum number of rows\"",
"+",
"\" or columns has been exceeded.\"",
")",
";",
"}",
"}",
"}"
] | Provides the results of a QR decomposition. These will be modified by adding or removing
rows from the original 'A' matrix.
@param Q The Q matrix which is to be modified. Is modified later and reference saved.
@param R The R matrix which is to be modified. Is modified later and reference saved. | [
"Provides",
"the",
"results",
"of",
"a",
"QR",
"decomposition",
".",
"These",
"will",
"be",
"modified",
"by",
"adding",
"or",
"removing",
"rows",
"from",
"the",
"original",
"A",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L215-L234 |
162,357 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.updateRemoveQ | private void updateRemoveQ( int rowIndex ) {
Qm.set(Q);
Q.reshape(m_m,m_m, false);
for( int i = 0; i < rowIndex; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[i*m_m+j-1] = sum;
}
}
for( int i = rowIndex+1; i < m; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[(i-1)*m_m+j-1] = sum;
}
}
} | java | private void updateRemoveQ( int rowIndex ) {
Qm.set(Q);
Q.reshape(m_m,m_m, false);
for( int i = 0; i < rowIndex; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[i*m_m+j-1] = sum;
}
}
for( int i = rowIndex+1; i < m; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[(i-1)*m_m+j-1] = sum;
}
}
} | [
"private",
"void",
"updateRemoveQ",
"(",
"int",
"rowIndex",
")",
"{",
"Qm",
".",
"set",
"(",
"Q",
")",
";",
"Q",
".",
"reshape",
"(",
"m_m",
",",
"m_m",
",",
"false",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowIndex",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
"<",
"m",
";",
"j",
"++",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"m",
";",
"k",
"++",
")",
"{",
"sum",
"+=",
"Qm",
".",
"data",
"[",
"i",
"*",
"m",
"+",
"k",
"]",
"*",
"U_tran",
".",
"data",
"[",
"j",
"*",
"m",
"+",
"k",
"]",
";",
"}",
"Q",
".",
"data",
"[",
"i",
"*",
"m_m",
"+",
"j",
"-",
"1",
"]",
"=",
"sum",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"rowIndex",
"+",
"1",
";",
"i",
"<",
"m",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
"<",
"m",
";",
"j",
"++",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"m",
";",
"k",
"++",
")",
"{",
"sum",
"+=",
"Qm",
".",
"data",
"[",
"i",
"*",
"m",
"+",
"k",
"]",
"*",
"U_tran",
".",
"data",
"[",
"j",
"*",
"m",
"+",
"k",
"]",
";",
"}",
"Q",
".",
"data",
"[",
"(",
"i",
"-",
"1",
")",
"*",
"m_m",
"+",
"j",
"-",
"1",
"]",
"=",
"sum",
";",
"}",
"}",
"}"
] | Updates the Q matrix to take inaccount the row that was removed by only multiplying e
lements that need to be. There is still some room for improvement here...
@param rowIndex | [
"Updates",
"the",
"Q",
"matrix",
"to",
"take",
"inaccount",
"the",
"row",
"that",
"was",
"removed",
"by",
"only",
"multiplying",
"e",
"lements",
"that",
"need",
"to",
"be",
".",
"There",
"is",
"still",
"some",
"room",
"for",
"improvement",
"here",
"..."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L275-L298 |
162,358 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.updateRemoveR | private void updateRemoveR() {
for( int i = 1; i < n+1; i++ ) {
for( int j = 0; j < n; j++ ) {
double sum = 0;
for( int k = i-1; k <= j; k++ ) {
sum += U_tran.data[i*m+k] * R.data[k*n+j];
}
R.data[(i-1)*n+j] = sum;
}
}
} | java | private void updateRemoveR() {
for( int i = 1; i < n+1; i++ ) {
for( int j = 0; j < n; j++ ) {
double sum = 0;
for( int k = i-1; k <= j; k++ ) {
sum += U_tran.data[i*m+k] * R.data[k*n+j];
}
R.data[(i-1)*n+j] = sum;
}
}
} | [
"private",
"void",
"updateRemoveR",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"n",
"+",
"1",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"k",
"=",
"i",
"-",
"1",
";",
"k",
"<=",
"j",
";",
"k",
"++",
")",
"{",
"sum",
"+=",
"U_tran",
".",
"data",
"[",
"i",
"*",
"m",
"+",
"k",
"]",
"*",
"R",
".",
"data",
"[",
"k",
"*",
"n",
"+",
"j",
"]",
";",
"}",
"R",
".",
"data",
"[",
"(",
"i",
"-",
"1",
")",
"*",
"n",
"+",
"j",
"]",
"=",
"sum",
";",
"}",
"}",
"}"
] | Updates the R matrix to take in account the removed row. | [
"Updates",
"the",
"R",
"matrix",
"to",
"take",
"in",
"account",
"the",
"removed",
"row",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L303-L313 |
162,359 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normalizeF | public static void normalizeF( DMatrixRMaj A ) {
double val = normF(A);
if( val == 0 )
return;
int size = A.getNumElements();
for( int i = 0; i < size; i++) {
A.div(i , val);
}
} | java | public static void normalizeF( DMatrixRMaj A ) {
double val = normF(A);
if( val == 0 )
return;
int size = A.getNumElements();
for( int i = 0; i < size; i++) {
A.div(i , val);
}
} | [
"public",
"static",
"void",
"normalizeF",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"double",
"val",
"=",
"normF",
"(",
"A",
")",
";",
"if",
"(",
"val",
"==",
"0",
")",
"return",
";",
"int",
"size",
"=",
"A",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"A",
".",
"div",
"(",
"i",
",",
"val",
")",
";",
"}",
"}"
] | Normalizes the matrix such that the Frobenius norm is equal to one.
@param A The matrix that is to be normalized. | [
"Normalizes",
"the",
"matrix",
"such",
"that",
"the",
"Frobenius",
"norm",
"is",
"equal",
"to",
"one",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L71-L82 |
162,360 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP | public static double normP(DMatrixRMaj A , double p ) {
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return normP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return elementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | java | public static double normP(DMatrixRMaj A , double p ) {
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return normP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return elementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | [
"public",
"static",
"double",
"normP",
"(",
"DMatrixRMaj",
"A",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"1",
")",
"{",
"return",
"normP1",
"(",
"A",
")",
";",
"}",
"else",
"if",
"(",
"p",
"==",
"2",
")",
"{",
"return",
"normP2",
"(",
"A",
")",
";",
"}",
"else",
"if",
"(",
"Double",
".",
"isInfinite",
"(",
"p",
")",
")",
"{",
"return",
"normPInf",
"(",
"A",
")",
";",
"}",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"elementP",
"(",
"A",
",",
"p",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Doesn't support induced norms yet.\"",
")",
";",
"}",
"}"
] | Computes either the vector p-norm or the induced matrix p-norm depending on A
being a vector or a matrix respectively.
@param A Vector or matrix whose norm is to be computed.
@param p The p value of the p-norm.
@return The computed norm. | [
"Computes",
"either",
"the",
"vector",
"p",
"-",
"norm",
"or",
"the",
"induced",
"matrix",
"p",
"-",
"norm",
"depending",
"on",
"A",
"being",
"a",
"vector",
"or",
"a",
"matrix",
"respectively",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L285-L298 |
162,361 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP1 | public static double normP1( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return CommonOps_DDRM.elementSumAbs(A);
} else {
return inducedP1(A);
}
} | java | public static double normP1( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return CommonOps_DDRM.elementSumAbs(A);
} else {
return inducedP1(A);
}
} | [
"public",
"static",
"double",
"normP1",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"CommonOps_DDRM",
".",
"elementSumAbs",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"inducedP1",
"(",
"A",
")",
";",
"}",
"}"
] | Computes the p=1 norm. If A is a matrix then the induced norm is computed.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"1",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L329-L335 |
162,362 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP2 | public static double normP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return normF(A);
} else {
return inducedP2(A);
}
} | java | public static double normP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return normF(A);
} else {
return inducedP2(A);
}
} | [
"public",
"static",
"double",
"normP2",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"normF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"inducedP2",
"(",
"A",
")",
";",
"}",
"}"
] | Computes the p=2 norm. If A is a matrix then the induced norm is computed.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"2",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L343-L349 |
162,363 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.fastNormP2 | public static double fastNormP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return fastNormF(A);
} else {
return inducedP2(A);
}
} | java | public static double fastNormP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return fastNormF(A);
} else {
return inducedP2(A);
}
} | [
"public",
"static",
"double",
"fastNormP2",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"fastNormF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"inducedP2",
"(",
"A",
")",
";",
"}",
"}"
] | Computes the p=2 norm. If A is a matrix then the induced norm is computed. This
implementation is faster, but more prone to buffer overflow or underflow problems.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"2",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
".",
"This",
"implementation",
"is",
"faster",
"but",
"more",
"prone",
"to",
"buffer",
"overflow",
"or",
"underflow",
"problems",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L358-L364 |
162,364 | lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ReadCsv.java | ReadCsv.extractWords | protected List<String> extractWords() throws IOException
{
while( true ) {
lineNumber++;
String line = in.readLine();
if( line == null ) {
return null;
}
// skip comment lines
if( hasComment ) {
if( line.charAt(0) == comment )
continue;
}
// extract the words, which are the variables encoded
return parseWords(line);
}
} | java | protected List<String> extractWords() throws IOException
{
while( true ) {
lineNumber++;
String line = in.readLine();
if( line == null ) {
return null;
}
// skip comment lines
if( hasComment ) {
if( line.charAt(0) == comment )
continue;
}
// extract the words, which are the variables encoded
return parseWords(line);
}
} | [
"protected",
"List",
"<",
"String",
">",
"extractWords",
"(",
")",
"throws",
"IOException",
"{",
"while",
"(",
"true",
")",
"{",
"lineNumber",
"++",
";",
"String",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// skip comment lines",
"if",
"(",
"hasComment",
")",
"{",
"if",
"(",
"line",
".",
"charAt",
"(",
"0",
")",
"==",
"comment",
")",
"continue",
";",
"}",
"// extract the words, which are the variables encoded",
"return",
"parseWords",
"(",
"line",
")",
";",
"}",
"}"
] | Finds the next valid line of words in the stream and extracts them.
@return List of valid words on the line. null if the end of the file has been reached.
@throws java.io.IOException | [
"Finds",
"the",
"next",
"valid",
"line",
"of",
"words",
"in",
"the",
"stream",
"and",
"extracts",
"them",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ReadCsv.java#L96-L114 |
162,365 | lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ReadCsv.java | ReadCsv.parseWords | protected List<String> parseWords(String line) {
List<String> words = new ArrayList<String>();
boolean insideWord = !isSpace(line.charAt(0));
int last = 0;
for( int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if( insideWord ) {
// see if its at the end of a word
if( isSpace(c)) {
words.add( line.substring(last,i) );
insideWord = false;
}
} else {
if( !isSpace(c)) {
last = i;
insideWord = true;
}
}
}
// if the line ended add the final word
if( insideWord ) {
words.add( line.substring(last));
}
return words;
} | java | protected List<String> parseWords(String line) {
List<String> words = new ArrayList<String>();
boolean insideWord = !isSpace(line.charAt(0));
int last = 0;
for( int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if( insideWord ) {
// see if its at the end of a word
if( isSpace(c)) {
words.add( line.substring(last,i) );
insideWord = false;
}
} else {
if( !isSpace(c)) {
last = i;
insideWord = true;
}
}
}
// if the line ended add the final word
if( insideWord ) {
words.add( line.substring(last));
}
return words;
} | [
"protected",
"List",
"<",
"String",
">",
"parseWords",
"(",
"String",
"line",
")",
"{",
"List",
"<",
"String",
">",
"words",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"boolean",
"insideWord",
"=",
"!",
"isSpace",
"(",
"line",
".",
"charAt",
"(",
"0",
")",
")",
";",
"int",
"last",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"line",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"line",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"insideWord",
")",
"{",
"// see if its at the end of a word",
"if",
"(",
"isSpace",
"(",
"c",
")",
")",
"{",
"words",
".",
"add",
"(",
"line",
".",
"substring",
"(",
"last",
",",
"i",
")",
")",
";",
"insideWord",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"isSpace",
"(",
"c",
")",
")",
"{",
"last",
"=",
"i",
";",
"insideWord",
"=",
"true",
";",
"}",
"}",
"}",
"// if the line ended add the final word",
"if",
"(",
"insideWord",
")",
"{",
"words",
".",
"add",
"(",
"line",
".",
"substring",
"(",
"last",
")",
")",
";",
"}",
"return",
"words",
";",
"}"
] | Extracts the words from a string. Words are seperated by a space character.
@param line The line that is being parsed.
@return A list of words contained on the line. | [
"Extracts",
"the",
"words",
"from",
"a",
"string",
".",
"Words",
"are",
"seperated",
"by",
"a",
"space",
"character",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ReadCsv.java#L122-L148 |
162,366 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.findMax | public static double findMax( double[] u, int startU , int length ) {
double max = -1;
int index = startU*2;
int stopIndex = (startU + length)*2;
for( ; index < stopIndex;) {
double real = u[index++];
double img = u[index++];
double val = real*real + img*img;
if( val > max ) {
max = val;
}
}
return Math.sqrt(max);
} | java | public static double findMax( double[] u, int startU , int length ) {
double max = -1;
int index = startU*2;
int stopIndex = (startU + length)*2;
for( ; index < stopIndex;) {
double real = u[index++];
double img = u[index++];
double val = real*real + img*img;
if( val > max ) {
max = val;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"findMax",
"(",
"double",
"[",
"]",
"u",
",",
"int",
"startU",
",",
"int",
"length",
")",
"{",
"double",
"max",
"=",
"-",
"1",
";",
"int",
"index",
"=",
"startU",
"*",
"2",
";",
"int",
"stopIndex",
"=",
"(",
"startU",
"+",
"length",
")",
"*",
"2",
";",
"for",
"(",
";",
"index",
"<",
"stopIndex",
";",
")",
"{",
"double",
"real",
"=",
"u",
"[",
"index",
"++",
"]",
";",
"double",
"img",
"=",
"u",
"[",
"index",
"++",
"]",
";",
"double",
"val",
"=",
"real",
"*",
"real",
"+",
"img",
"*",
"img",
";",
"if",
"(",
"val",
">",
"max",
")",
"{",
"max",
"=",
"val",
";",
"}",
"}",
"return",
"Math",
".",
"sqrt",
"(",
"max",
")",
";",
"}"
] | Returns the maximum magnitude of the complex numbers
@param u Array of complex numbers
@param startU first index to consider in u
@param length Number of complex numebrs to consider
@return magnitude | [
"Returns",
"the",
"maximum",
"magnitude",
"of",
"the",
"complex",
"numbers"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L55-L72 |
162,367 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractHouseholderColumn | public static void extractHouseholderColumn( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU )
{
int indexU = (row0+offsetU)*2;
u[indexU++] = 1;
u[indexU++] = 0;
for (int row = row0+1; row < row1; row++) {
int indexA = A.getIndex(row,col);
u[indexU++] = A.data[indexA];
u[indexU++] = A.data[indexA+1];
}
} | java | public static void extractHouseholderColumn( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU )
{
int indexU = (row0+offsetU)*2;
u[indexU++] = 1;
u[indexU++] = 0;
for (int row = row0+1; row < row1; row++) {
int indexA = A.getIndex(row,col);
u[indexU++] = A.data[indexA];
u[indexU++] = A.data[indexA+1];
}
} | [
"public",
"static",
"void",
"extractHouseholderColumn",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row0",
",",
"int",
"row1",
",",
"int",
"col",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"row0",
"+",
"offsetU",
")",
"*",
"2",
";",
"u",
"[",
"indexU",
"++",
"]",
"=",
"1",
";",
"u",
"[",
"indexU",
"++",
"]",
"=",
"0",
";",
"for",
"(",
"int",
"row",
"=",
"row0",
"+",
"1",
";",
"row",
"<",
"row1",
";",
"row",
"++",
")",
"{",
"int",
"indexA",
"=",
"A",
".",
"getIndex",
"(",
"row",
",",
"col",
")",
";",
"u",
"[",
"indexU",
"++",
"]",
"=",
"A",
".",
"data",
"[",
"indexA",
"]",
";",
"u",
"[",
"indexU",
"++",
"]",
"=",
"A",
".",
"data",
"[",
"indexA",
"+",
"1",
"]",
";",
"}",
"}"
] | Extracts a house holder vector from the column of A and stores it in u
@param A Complex matrix with householder vectors stored in the lower left triangle
@param row0 first row in A (implicitly assumed to be r + i0)
@param row1 last row + 1 in A
@param col Column in A
@param u Output array storage
@param offsetU first index in U | [
"Extracts",
"a",
"house",
"holder",
"vector",
"from",
"the",
"column",
"of",
"A",
"and",
"stores",
"it",
"in",
"u"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L319-L332 |
162,368 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractHouseholderRow | public static void extractHouseholderRow( ZMatrixRMaj A ,
int row ,
int col0, int col1 , double u[], int offsetU )
{
int indexU = (offsetU+col0)*2;
u[indexU] = 1;
u[indexU+1] = 0;
int indexA = (row*A.numCols + (col0+1))*2;
System.arraycopy(A.data,indexA,u,indexU+2,(col1-col0-1)*2);
} | java | public static void extractHouseholderRow( ZMatrixRMaj A ,
int row ,
int col0, int col1 , double u[], int offsetU )
{
int indexU = (offsetU+col0)*2;
u[indexU] = 1;
u[indexU+1] = 0;
int indexA = (row*A.numCols + (col0+1))*2;
System.arraycopy(A.data,indexA,u,indexU+2,(col1-col0-1)*2);
} | [
"public",
"static",
"void",
"extractHouseholderRow",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row",
",",
"int",
"col0",
",",
"int",
"col1",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"offsetU",
"+",
"col0",
")",
"*",
"2",
";",
"u",
"[",
"indexU",
"]",
"=",
"1",
";",
"u",
"[",
"indexU",
"+",
"1",
"]",
"=",
"0",
";",
"int",
"indexA",
"=",
"(",
"row",
"*",
"A",
".",
"numCols",
"+",
"(",
"col0",
"+",
"1",
")",
")",
"*",
"2",
";",
"System",
".",
"arraycopy",
"(",
"A",
".",
"data",
",",
"indexA",
",",
"u",
",",
"indexU",
"+",
"2",
",",
"(",
"col1",
"-",
"col0",
"-",
"1",
")",
"*",
"2",
")",
";",
"}"
] | Extracts a house holder vector from the rows of A and stores it in u
@param A Complex matrix with householder vectors stored in the upper right triangle
@param row Row in A
@param col0 first row in A (implicitly assumed to be r + i0)
@param col1 last row +1 in A
@param u Output array storage
@param offsetU first index in U | [
"Extracts",
"a",
"house",
"holder",
"vector",
"from",
"the",
"rows",
"of",
"A",
"and",
"stores",
"it",
"in",
"u"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L343-L353 |
162,369 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractColumnAndMax | public static double extractColumnAndMax( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU) {
int indexU = (offsetU+row0)*2;
// find the largest value in this column
// this is used to normalize the column and mitigate overflow/underflow
double max = 0;
int indexA = A.getIndex(row0,col);
double h[] = A.data;
for( int i = row0; i < row1; i++, indexA += A.numCols*2 ) {
// copy the householder vector to an array to reduce cache misses
// big improvement on larger matrices and a relatively small performance hit on small matrices.
double realVal = u[indexU++] = h[indexA];
double imagVal = u[indexU++] = h[indexA+1];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | java | public static double extractColumnAndMax( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU) {
int indexU = (offsetU+row0)*2;
// find the largest value in this column
// this is used to normalize the column and mitigate overflow/underflow
double max = 0;
int indexA = A.getIndex(row0,col);
double h[] = A.data;
for( int i = row0; i < row1; i++, indexA += A.numCols*2 ) {
// copy the householder vector to an array to reduce cache misses
// big improvement on larger matrices and a relatively small performance hit on small matrices.
double realVal = u[indexU++] = h[indexA];
double imagVal = u[indexU++] = h[indexA+1];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"extractColumnAndMax",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row0",
",",
"int",
"row1",
",",
"int",
"col",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"offsetU",
"+",
"row0",
")",
"*",
"2",
";",
"// find the largest value in this column",
"// this is used to normalize the column and mitigate overflow/underflow",
"double",
"max",
"=",
"0",
";",
"int",
"indexA",
"=",
"A",
".",
"getIndex",
"(",
"row0",
",",
"col",
")",
";",
"double",
"h",
"[",
"]",
"=",
"A",
".",
"data",
";",
"for",
"(",
"int",
"i",
"=",
"row0",
";",
"i",
"<",
"row1",
";",
"i",
"++",
",",
"indexA",
"+=",
"A",
".",
"numCols",
"*",
"2",
")",
"{",
"// copy the householder vector to an array to reduce cache misses",
"// big improvement on larger matrices and a relatively small performance hit on small matrices.",
"double",
"realVal",
"=",
"u",
"[",
"indexU",
"++",
"]",
"=",
"h",
"[",
"indexA",
"]",
";",
"double",
"imagVal",
"=",
"u",
"[",
"indexU",
"++",
"]",
"=",
"h",
"[",
"indexA",
"+",
"1",
"]",
";",
"double",
"magVal",
"=",
"realVal",
"*",
"realVal",
"+",
"imagVal",
"*",
"imagVal",
";",
"if",
"(",
"max",
"<",
"magVal",
")",
"{",
"max",
"=",
"magVal",
";",
"}",
"}",
"return",
"Math",
".",
"sqrt",
"(",
"max",
")",
";",
"}"
] | Extracts the column of A and copies it into u while computing the magnitude of the
largest element and returning it.
<pre>
u[ (offsetU+row0+i)*2 ] = A.getReal(row0+i,col)
u[ (offsetU+row0+i)*2 + 1] = A.getImag(row0+i,col)
</pre>
@param A Complex matrix
@param row0 First row in A to be copied
@param row1 Last row in A + 1 to be copied
@param col Column in A
@param u Output array storage
@param offsetU first index in U
@return magnitude of largest element | [
"Extracts",
"the",
"column",
"of",
"A",
"and",
"copies",
"it",
"into",
"u",
"while",
"computing",
"the",
"magnitude",
"of",
"the",
"largest",
"element",
"and",
"returning",
"it",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L372-L396 |
162,370 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.computeRowMax | public static double computeRowMax( ZMatrixRMaj A ,
int row , int col0 , int col1 ) {
double max = 0;
int indexA = A.getIndex(row,col0);
double h[] = A.data;
for (int i = col0; i < col1; i++) {
double realVal = h[indexA++];
double imagVal = h[indexA++];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | java | public static double computeRowMax( ZMatrixRMaj A ,
int row , int col0 , int col1 ) {
double max = 0;
int indexA = A.getIndex(row,col0);
double h[] = A.data;
for (int i = col0; i < col1; i++) {
double realVal = h[indexA++];
double imagVal = h[indexA++];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"computeRowMax",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row",
",",
"int",
"col0",
",",
"int",
"col1",
")",
"{",
"double",
"max",
"=",
"0",
";",
"int",
"indexA",
"=",
"A",
".",
"getIndex",
"(",
"row",
",",
"col0",
")",
";",
"double",
"h",
"[",
"]",
"=",
"A",
".",
"data",
";",
"for",
"(",
"int",
"i",
"=",
"col0",
";",
"i",
"<",
"col1",
";",
"i",
"++",
")",
"{",
"double",
"realVal",
"=",
"h",
"[",
"indexA",
"++",
"]",
";",
"double",
"imagVal",
"=",
"h",
"[",
"indexA",
"++",
"]",
";",
"double",
"magVal",
"=",
"realVal",
"*",
"realVal",
"+",
"imagVal",
"*",
"imagVal",
";",
"if",
"(",
"max",
"<",
"magVal",
")",
"{",
"max",
"=",
"magVal",
";",
"}",
"}",
"return",
"Math",
".",
"sqrt",
"(",
"max",
")",
";",
"}"
] | Finds the magnitude of the largest element in the row
@param A Complex matrix
@param row Row in A
@param col0 First column in A to be copied
@param col1 Last column in A + 1 to be copied
@return magnitude of largest element | [
"Finds",
"the",
"magnitude",
"of",
"the",
"largest",
"element",
"in",
"the",
"row"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L406-L423 |
162,371 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java | RandomMatrices_ZDRM.hermitian | public static ZMatrixRMaj hermitian(int length, double min, double max, Random rand) {
ZMatrixRMaj A = new ZMatrixRMaj(length,length);
fillHermitian(A, min, max, rand);
return A;
} | java | public static ZMatrixRMaj hermitian(int length, double min, double max, Random rand) {
ZMatrixRMaj A = new ZMatrixRMaj(length,length);
fillHermitian(A, min, max, rand);
return A;
} | [
"public",
"static",
"ZMatrixRMaj",
"hermitian",
"(",
"int",
"length",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"ZMatrixRMaj",
"A",
"=",
"new",
"ZMatrixRMaj",
"(",
"length",
",",
"length",
")",
";",
"fillHermitian",
"(",
"A",
",",
"min",
",",
"max",
",",
"rand",
")",
";",
"return",
"A",
";",
"}"
] | Creates a random Hermitian matrix with elements from min to max value.
@param length Width and height of the matrix.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator.
@return A symmetric matrix. | [
"Creates",
"a",
"random",
"Hermitian",
"matrix",
"with",
"elements",
"from",
"min",
"to",
"max",
"value",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java#L135-L141 |
162,372 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java | RandomMatrices_ZDRM.fillHermitian | public static void fillHermitian(ZMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
A.set(i,i,rand.nextDouble()*range + min,0);
for( int j = i+1; j < length; j++ ) {
double real = rand.nextDouble()*range + min;
double imaginary = rand.nextDouble()*range + min;
A.set(i,j,real,imaginary);
A.set(j,i,real,-imaginary);
}
}
} | java | public static void fillHermitian(ZMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
A.set(i,i,rand.nextDouble()*range + min,0);
for( int j = i+1; j < length; j++ ) {
double real = rand.nextDouble()*range + min;
double imaginary = rand.nextDouble()*range + min;
A.set(i,j,real,imaginary);
A.set(j,i,real,-imaginary);
}
}
} | [
"public",
"static",
"void",
"fillHermitian",
"(",
"ZMatrixRMaj",
"A",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A must be a square matrix\"",
")",
";",
"double",
"range",
"=",
"max",
"-",
"min",
";",
"int",
"length",
"=",
"A",
".",
"numRows",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"A",
".",
"set",
"(",
"i",
",",
"i",
",",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"range",
"+",
"min",
",",
"0",
")",
";",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"length",
";",
"j",
"++",
")",
"{",
"double",
"real",
"=",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"range",
"+",
"min",
";",
"double",
"imaginary",
"=",
"rand",
".",
"nextDouble",
"(",
")",
"*",
"range",
"+",
"min",
";",
"A",
".",
"set",
"(",
"i",
",",
"j",
",",
"real",
",",
"imaginary",
")",
";",
"A",
".",
"set",
"(",
"j",
",",
"i",
",",
"real",
",",
"-",
"imaginary",
")",
";",
"}",
"}",
"}"
] | Assigns the provided square matrix to be a random Hermitian matrix with elements from min to max value.
@param A The matrix that is to be modified. Must be square. Modified.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator. | [
"Assigns",
"the",
"provided",
"square",
"matrix",
"to",
"be",
"a",
"random",
"Hermitian",
"matrix",
"with",
"elements",
"from",
"min",
"to",
"max",
"value",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java#L151-L169 |
162,373 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java | SimpleMatrix.wrap | public static SimpleMatrix wrap( Matrix internalMat ) {
SimpleMatrix ret = new SimpleMatrix();
ret.setMatrix(internalMat);
return ret;
} | java | public static SimpleMatrix wrap( Matrix internalMat ) {
SimpleMatrix ret = new SimpleMatrix();
ret.setMatrix(internalMat);
return ret;
} | [
"public",
"static",
"SimpleMatrix",
"wrap",
"(",
"Matrix",
"internalMat",
")",
"{",
"SimpleMatrix",
"ret",
"=",
"new",
"SimpleMatrix",
"(",
")",
";",
"ret",
".",
"setMatrix",
"(",
"internalMat",
")",
";",
"return",
"ret",
";",
"}"
] | Creates a new SimpleMatrix with the specified DMatrixRMaj used as its internal matrix. This means
that the reference is saved and calls made to the returned SimpleMatrix will modify the passed in DMatrixRMaj.
@param internalMat The internal DMatrixRMaj of the returned SimpleMatrix. Will be modified. | [
"Creates",
"a",
"new",
"SimpleMatrix",
"with",
"the",
"specified",
"DMatrixRMaj",
"used",
"as",
"its",
"internal",
"matrix",
".",
"This",
"means",
"that",
"the",
"reference",
"is",
"saved",
"and",
"calls",
"made",
"to",
"the",
"returned",
"SimpleMatrix",
"will",
"modify",
"the",
"passed",
"in",
"DMatrixRMaj",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java#L221-L225 |
162,374 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java | SimpleMatrix.diag | public static SimpleMatrix diag( Class type, double ...vals ) {
SimpleMatrix M = new SimpleMatrix(vals.length,vals.length,type);
for (int i = 0; i < vals.length; i++) {
M.set(i,i,vals[i]);
}
return M;
} | java | public static SimpleMatrix diag( Class type, double ...vals ) {
SimpleMatrix M = new SimpleMatrix(vals.length,vals.length,type);
for (int i = 0; i < vals.length; i++) {
M.set(i,i,vals[i]);
}
return M;
} | [
"public",
"static",
"SimpleMatrix",
"diag",
"(",
"Class",
"type",
",",
"double",
"...",
"vals",
")",
"{",
"SimpleMatrix",
"M",
"=",
"new",
"SimpleMatrix",
"(",
"vals",
".",
"length",
",",
"vals",
".",
"length",
",",
"type",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vals",
".",
"length",
";",
"i",
"++",
")",
"{",
"M",
".",
"set",
"(",
"i",
",",
"i",
",",
"vals",
"[",
"i",
"]",
")",
";",
"}",
"return",
"M",
";",
"}"
] | Creates a real valued diagonal matrix of the specified type | [
"Creates",
"a",
"real",
"valued",
"diagonal",
"matrix",
"of",
"the",
"specified",
"type"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java#L269-L275 |
162,375 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java | CommonOps_ZDRM.convert | public static void convert(DMatrixD1 input , ZMatrixD1 output ) {
if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
Arrays.fill(output.data, 0, output.getDataLength(), 0);
final int length = output.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i] = input.data[i/2];
}
} | java | public static void convert(DMatrixD1 input , ZMatrixD1 output ) {
if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
Arrays.fill(output.data, 0, output.getDataLength(), 0);
final int length = output.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i] = input.data[i/2];
}
} | [
"public",
"static",
"void",
"convert",
"(",
"DMatrixD1",
"input",
",",
"ZMatrixD1",
"output",
")",
"{",
"if",
"(",
"input",
".",
"numCols",
"!=",
"output",
".",
"numCols",
"||",
"input",
".",
"numRows",
"!=",
"output",
".",
"numRows",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The matrices are not all the same dimension.\"",
")",
";",
"}",
"Arrays",
".",
"fill",
"(",
"output",
".",
"data",
",",
"0",
",",
"output",
".",
"getDataLength",
"(",
")",
",",
"0",
")",
";",
"final",
"int",
"length",
"=",
"output",
".",
"getDataLength",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"output",
".",
"data",
"[",
"i",
"]",
"=",
"input",
".",
"data",
"[",
"i",
"/",
"2",
"]",
";",
"}",
"}"
] | Converts the real matrix into a complex matrix.
@param input Real matrix. Not modified.
@param output Complex matrix. Modified. | [
"Converts",
"the",
"real",
"matrix",
"into",
"a",
"complex",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java#L144-L156 |
162,376 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java | CommonOps_ZDRM.stripReal | public static DMatrixRMaj stripReal(ZMatrixD1 input , DMatrixRMaj output ) {
if( output == null ) {
output = new DMatrixRMaj(input.numRows,input.numCols);
} else if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
final int length = input.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i/2] = input.data[i];
}
return output;
} | java | public static DMatrixRMaj stripReal(ZMatrixD1 input , DMatrixRMaj output ) {
if( output == null ) {
output = new DMatrixRMaj(input.numRows,input.numCols);
} else if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
final int length = input.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i/2] = input.data[i];
}
return output;
} | [
"public",
"static",
"DMatrixRMaj",
"stripReal",
"(",
"ZMatrixD1",
"input",
",",
"DMatrixRMaj",
"output",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"output",
"=",
"new",
"DMatrixRMaj",
"(",
"input",
".",
"numRows",
",",
"input",
".",
"numCols",
")",
";",
"}",
"else",
"if",
"(",
"input",
".",
"numCols",
"!=",
"output",
".",
"numCols",
"||",
"input",
".",
"numRows",
"!=",
"output",
".",
"numRows",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The matrices are not all the same dimension.\"",
")",
";",
"}",
"final",
"int",
"length",
"=",
"input",
".",
"getDataLength",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"output",
".",
"data",
"[",
"i",
"/",
"2",
"]",
"=",
"input",
".",
"data",
"[",
"i",
"]",
";",
"}",
"return",
"output",
";",
"}"
] | Places the real component of the input matrix into the output matrix.
@param input Complex matrix. Not modified.
@param output real matrix. Modified. | [
"Places",
"the",
"real",
"component",
"of",
"the",
"input",
"matrix",
"into",
"the",
"output",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java#L164-L177 |
162,377 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.convert | public static DMatrixRMaj convert(DMatrixRBlock src , DMatrixRMaj dst )
{
return ConvertDMatrixStruct.convert(src,dst);
} | java | public static DMatrixRMaj convert(DMatrixRBlock src , DMatrixRMaj dst )
{
return ConvertDMatrixStruct.convert(src,dst);
} | [
"public",
"static",
"DMatrixRMaj",
"convert",
"(",
"DMatrixRBlock",
"src",
",",
"DMatrixRMaj",
"dst",
")",
"{",
"return",
"ConvertDMatrixStruct",
".",
"convert",
"(",
"src",
",",
"dst",
")",
";",
"}"
] | Converts a row major block matrix into a row major matrix.
@param src Original DMatrixRBlock.. Not modified.
@param dst Equivalent DMatrixRMaj. Modified. | [
"Converts",
"a",
"row",
"major",
"block",
"matrix",
"into",
"a",
"row",
"major",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L96-L99 |
162,378 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.convertTranSrc | public static void convertTranSrc(DMatrixRMaj src , DMatrixRBlock dst )
{
if( src.numRows != dst.numCols || src.numCols != dst.numRows )
throw new IllegalArgumentException("Incompatible matrix shapes.");
for( int i = 0; i < dst.numRows; i += dst.blockLength ) {
int blockHeight = Math.min( dst.blockLength , dst.numRows - i);
for( int j = 0; j < dst.numCols; j += dst.blockLength ) {
int blockWidth = Math.min( dst.blockLength , dst.numCols - j);
int indexDst = i*dst.numCols + blockHeight*j;
int indexSrc = j*src.numCols + i;
for( int l = 0; l < blockWidth; l++ ) {
int rowSrc = indexSrc + l*src.numCols;
int rowDst = indexDst + l;
for( int k = 0; k < blockHeight; k++ , rowDst += blockWidth ) {
dst.data[ rowDst ] = src.data[rowSrc++];
}
}
}
}
} | java | public static void convertTranSrc(DMatrixRMaj src , DMatrixRBlock dst )
{
if( src.numRows != dst.numCols || src.numCols != dst.numRows )
throw new IllegalArgumentException("Incompatible matrix shapes.");
for( int i = 0; i < dst.numRows; i += dst.blockLength ) {
int blockHeight = Math.min( dst.blockLength , dst.numRows - i);
for( int j = 0; j < dst.numCols; j += dst.blockLength ) {
int blockWidth = Math.min( dst.blockLength , dst.numCols - j);
int indexDst = i*dst.numCols + blockHeight*j;
int indexSrc = j*src.numCols + i;
for( int l = 0; l < blockWidth; l++ ) {
int rowSrc = indexSrc + l*src.numCols;
int rowDst = indexDst + l;
for( int k = 0; k < blockHeight; k++ , rowDst += blockWidth ) {
dst.data[ rowDst ] = src.data[rowSrc++];
}
}
}
}
} | [
"public",
"static",
"void",
"convertTranSrc",
"(",
"DMatrixRMaj",
"src",
",",
"DMatrixRBlock",
"dst",
")",
"{",
"if",
"(",
"src",
".",
"numRows",
"!=",
"dst",
".",
"numCols",
"||",
"src",
".",
"numCols",
"!=",
"dst",
".",
"numRows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Incompatible matrix shapes.\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dst",
".",
"numRows",
";",
"i",
"+=",
"dst",
".",
"blockLength",
")",
"{",
"int",
"blockHeight",
"=",
"Math",
".",
"min",
"(",
"dst",
".",
"blockLength",
",",
"dst",
".",
"numRows",
"-",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"dst",
".",
"numCols",
";",
"j",
"+=",
"dst",
".",
"blockLength",
")",
"{",
"int",
"blockWidth",
"=",
"Math",
".",
"min",
"(",
"dst",
".",
"blockLength",
",",
"dst",
".",
"numCols",
"-",
"j",
")",
";",
"int",
"indexDst",
"=",
"i",
"*",
"dst",
".",
"numCols",
"+",
"blockHeight",
"*",
"j",
";",
"int",
"indexSrc",
"=",
"j",
"*",
"src",
".",
"numCols",
"+",
"i",
";",
"for",
"(",
"int",
"l",
"=",
"0",
";",
"l",
"<",
"blockWidth",
";",
"l",
"++",
")",
"{",
"int",
"rowSrc",
"=",
"indexSrc",
"+",
"l",
"*",
"src",
".",
"numCols",
";",
"int",
"rowDst",
"=",
"indexDst",
"+",
"l",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"blockHeight",
";",
"k",
"++",
",",
"rowDst",
"+=",
"blockWidth",
")",
"{",
"dst",
".",
"data",
"[",
"rowDst",
"]",
"=",
"src",
".",
"data",
"[",
"rowSrc",
"++",
"]",
";",
"}",
"}",
"}",
"}",
"}"
] | Converts the transpose of a row major matrix into a row major block matrix.
@param src Original DMatrixRMaj. Not modified.
@param dst Equivalent DMatrixRBlock. Modified. | [
"Converts",
"the",
"transpose",
"of",
"a",
"row",
"major",
"matrix",
"into",
"a",
"row",
"major",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L146-L169 |
162,379 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.transpose | public static DMatrixRBlock transpose(DMatrixRBlock A , DMatrixRBlock A_tran )
{
if( A_tran != null ) {
if( A.numRows != A_tran.numCols || A.numCols != A_tran.numRows )
throw new IllegalArgumentException("Incompatible dimensions.");
if( A.blockLength != A_tran.blockLength )
throw new IllegalArgumentException("Incompatible block size.");
} else {
A_tran = new DMatrixRBlock(A.numCols,A.numRows,A.blockLength);
}
for( int i = 0; i < A.numRows; i += A.blockLength ) {
int blockHeight = Math.min( A.blockLength , A.numRows - i);
for( int j = 0; j < A.numCols; j += A.blockLength ) {
int blockWidth = Math.min( A.blockLength , A.numCols - j);
int indexA = i*A.numCols + blockHeight*j;
int indexC = j*A_tran.numCols + blockWidth*i;
transposeBlock( A , A_tran , indexA , indexC , blockWidth , blockHeight );
}
}
return A_tran;
} | java | public static DMatrixRBlock transpose(DMatrixRBlock A , DMatrixRBlock A_tran )
{
if( A_tran != null ) {
if( A.numRows != A_tran.numCols || A.numCols != A_tran.numRows )
throw new IllegalArgumentException("Incompatible dimensions.");
if( A.blockLength != A_tran.blockLength )
throw new IllegalArgumentException("Incompatible block size.");
} else {
A_tran = new DMatrixRBlock(A.numCols,A.numRows,A.blockLength);
}
for( int i = 0; i < A.numRows; i += A.blockLength ) {
int blockHeight = Math.min( A.blockLength , A.numRows - i);
for( int j = 0; j < A.numCols; j += A.blockLength ) {
int blockWidth = Math.min( A.blockLength , A.numCols - j);
int indexA = i*A.numCols + blockHeight*j;
int indexC = j*A_tran.numCols + blockWidth*i;
transposeBlock( A , A_tran , indexA , indexC , blockWidth , blockHeight );
}
}
return A_tran;
} | [
"public",
"static",
"DMatrixRBlock",
"transpose",
"(",
"DMatrixRBlock",
"A",
",",
"DMatrixRBlock",
"A_tran",
")",
"{",
"if",
"(",
"A_tran",
"!=",
"null",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A_tran",
".",
"numCols",
"||",
"A",
".",
"numCols",
"!=",
"A_tran",
".",
"numRows",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Incompatible dimensions.\"",
")",
";",
"if",
"(",
"A",
".",
"blockLength",
"!=",
"A_tran",
".",
"blockLength",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Incompatible block size.\"",
")",
";",
"}",
"else",
"{",
"A_tran",
"=",
"new",
"DMatrixRBlock",
"(",
"A",
".",
"numCols",
",",
"A",
".",
"numRows",
",",
"A",
".",
"blockLength",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"numRows",
";",
"i",
"+=",
"A",
".",
"blockLength",
")",
"{",
"int",
"blockHeight",
"=",
"Math",
".",
"min",
"(",
"A",
".",
"blockLength",
",",
"A",
".",
"numRows",
"-",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"A",
".",
"numCols",
";",
"j",
"+=",
"A",
".",
"blockLength",
")",
"{",
"int",
"blockWidth",
"=",
"Math",
".",
"min",
"(",
"A",
".",
"blockLength",
",",
"A",
".",
"numCols",
"-",
"j",
")",
";",
"int",
"indexA",
"=",
"i",
"*",
"A",
".",
"numCols",
"+",
"blockHeight",
"*",
"j",
";",
"int",
"indexC",
"=",
"j",
"*",
"A_tran",
".",
"numCols",
"+",
"blockWidth",
"*",
"i",
";",
"transposeBlock",
"(",
"A",
",",
"A_tran",
",",
"indexA",
",",
"indexC",
",",
"blockWidth",
",",
"blockHeight",
")",
";",
"}",
"}",
"return",
"A_tran",
";",
"}"
] | Transposes a block matrix.
@param A Original matrix. Not modified.
@param A_tran Transposed matrix. Modified. | [
"Transposes",
"a",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L239-L265 |
162,380 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.transposeBlock | private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
int indexA , int indexC ,
int width , int height )
{
for( int i = 0; i < height; i++ ) {
int rowIndexC = indexC + i;
int rowIndexA = indexA + width*i;
int end = rowIndexA + width;
for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
}
}
} | java | private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
int indexA , int indexC ,
int width , int height )
{
for( int i = 0; i < height; i++ ) {
int rowIndexC = indexC + i;
int rowIndexA = indexA + width*i;
int end = rowIndexA + width;
for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
}
}
} | [
"private",
"static",
"void",
"transposeBlock",
"(",
"DMatrixRBlock",
"A",
",",
"DMatrixRBlock",
"A_tran",
",",
"int",
"indexA",
",",
"int",
"indexC",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"height",
";",
"i",
"++",
")",
"{",
"int",
"rowIndexC",
"=",
"indexC",
"+",
"i",
";",
"int",
"rowIndexA",
"=",
"indexA",
"+",
"width",
"*",
"i",
";",
"int",
"end",
"=",
"rowIndexA",
"+",
"width",
";",
"for",
"(",
";",
"rowIndexA",
"<",
"end",
";",
"rowIndexC",
"+=",
"height",
",",
"rowIndexA",
"++",
")",
"{",
"A_tran",
".",
"data",
"[",
"rowIndexC",
"]",
"=",
"A",
".",
"data",
"[",
"rowIndexA",
"]",
";",
"}",
"}",
"}"
] | Transposes an individual block inside a block matrix. | [
"Transposes",
"an",
"individual",
"block",
"inside",
"a",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L270-L282 |
162,381 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.zeroTriangle | public static void zeroTriangle( boolean upper , DMatrixRBlock A )
{
int blockLength = A.blockLength;
if( upper ) {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = i; j < A.numCols; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
for( int l = k+1; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
} else {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = 0; j <= i; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
int z = Math.min(k,w);
for( int l = 0; l < z; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
}
} | java | public static void zeroTriangle( boolean upper , DMatrixRBlock A )
{
int blockLength = A.blockLength;
if( upper ) {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = i; j < A.numCols; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
for( int l = k+1; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
} else {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = 0; j <= i; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
int z = Math.min(k,w);
for( int l = 0; l < z; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
}
} | [
"public",
"static",
"void",
"zeroTriangle",
"(",
"boolean",
"upper",
",",
"DMatrixRBlock",
"A",
")",
"{",
"int",
"blockLength",
"=",
"A",
".",
"blockLength",
";",
"if",
"(",
"upper",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"numRows",
";",
"i",
"+=",
"blockLength",
")",
"{",
"int",
"h",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numRows",
"-",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"i",
";",
"j",
"<",
"A",
".",
"numCols",
";",
"j",
"+=",
"blockLength",
")",
"{",
"int",
"w",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numCols",
"-",
"j",
")",
";",
"int",
"index",
"=",
"i",
"*",
"A",
".",
"numCols",
"+",
"h",
"*",
"j",
";",
"if",
"(",
"j",
"==",
"i",
")",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"h",
";",
"k",
"++",
")",
"{",
"for",
"(",
"int",
"l",
"=",
"k",
"+",
"1",
";",
"l",
"<",
"w",
";",
"l",
"++",
")",
"{",
"A",
".",
"data",
"[",
"index",
"+",
"w",
"*",
"k",
"+",
"l",
"]",
"=",
"0",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"h",
";",
"k",
"++",
")",
"{",
"for",
"(",
"int",
"l",
"=",
"0",
";",
"l",
"<",
"w",
";",
"l",
"++",
")",
"{",
"A",
".",
"data",
"[",
"index",
"+",
"w",
"*",
"k",
"+",
"l",
"]",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"numRows",
";",
"i",
"+=",
"blockLength",
")",
"{",
"int",
"h",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numRows",
"-",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<=",
"i",
";",
"j",
"+=",
"blockLength",
")",
"{",
"int",
"w",
"=",
"Math",
".",
"min",
"(",
"blockLength",
",",
"A",
".",
"numCols",
"-",
"j",
")",
";",
"int",
"index",
"=",
"i",
"*",
"A",
".",
"numCols",
"+",
"h",
"*",
"j",
";",
"if",
"(",
"j",
"==",
"i",
")",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"h",
";",
"k",
"++",
")",
"{",
"int",
"z",
"=",
"Math",
".",
"min",
"(",
"k",
",",
"w",
")",
";",
"for",
"(",
"int",
"l",
"=",
"0",
";",
"l",
"<",
"z",
";",
"l",
"++",
")",
"{",
"A",
".",
"data",
"[",
"index",
"+",
"w",
"*",
"k",
"+",
"l",
"]",
"=",
"0",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"h",
";",
"k",
"++",
")",
"{",
"for",
"(",
"int",
"l",
"=",
"0",
";",
"l",
"<",
"w",
";",
"l",
"++",
")",
"{",
"A",
".",
"data",
"[",
"index",
"+",
"w",
"*",
"k",
"+",
"l",
"]",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
] | Sets either the upper or low triangle of a matrix to zero | [
"Sets",
"either",
"the",
"upper",
"or",
"low",
"triangle",
"of",
"a",
"matrix",
"to",
"zero"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L337-L391 |
162,382 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.blockAligned | public static boolean blockAligned( int blockLength , DSubmatrixD1 A ) {
if( A.col0 % blockLength != 0 )
return false;
if( A.row0 % blockLength != 0 )
return false;
if( A.col1 % blockLength != 0 && A.col1 != A.original.numCols ) {
return false;
}
if( A.row1 % blockLength != 0 && A.row1 != A.original.numRows) {
return false;
}
return true;
} | java | public static boolean blockAligned( int blockLength , DSubmatrixD1 A ) {
if( A.col0 % blockLength != 0 )
return false;
if( A.row0 % blockLength != 0 )
return false;
if( A.col1 % blockLength != 0 && A.col1 != A.original.numCols ) {
return false;
}
if( A.row1 % blockLength != 0 && A.row1 != A.original.numRows) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"blockAligned",
"(",
"int",
"blockLength",
",",
"DSubmatrixD1",
"A",
")",
"{",
"if",
"(",
"A",
".",
"col0",
"%",
"blockLength",
"!=",
"0",
")",
"return",
"false",
";",
"if",
"(",
"A",
".",
"row0",
"%",
"blockLength",
"!=",
"0",
")",
"return",
"false",
";",
"if",
"(",
"A",
".",
"col1",
"%",
"blockLength",
"!=",
"0",
"&&",
"A",
".",
"col1",
"!=",
"A",
".",
"original",
".",
"numCols",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"A",
".",
"row1",
"%",
"blockLength",
"!=",
"0",
"&&",
"A",
".",
"row1",
"!=",
"A",
".",
"original",
".",
"numRows",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Checks to see if the submatrix has its boundaries along inner blocks.
@param blockLength Size of an inner block.
@param A Submatrix.
@return If it is block aligned or not. | [
"Checks",
"to",
"see",
"if",
"the",
"submatrix",
"has",
"its",
"boundaries",
"along",
"inner",
"blocks",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L604-L619 |
162,383 | lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_Ultimate.java | SvdImplicitQrDecompose_Ultimate.makeSingularPositive | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = singularValues[i];
if( val < 0 ) {
singularValues[i] = -val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.data[j] = -Ut.data[j];
}
}
}
}
} | java | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = singularValues[i];
if( val < 0 ) {
singularValues[i] = -val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.data[j] = -Ut.data[j];
}
}
}
}
} | [
"private",
"void",
"makeSingularPositive",
"(",
")",
"{",
"numSingular",
"=",
"qralg",
".",
"getNumberOfSingularValues",
"(",
")",
";",
"singularValues",
"=",
"qralg",
".",
"getSingularValues",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numSingular",
";",
"i",
"++",
")",
"{",
"double",
"val",
"=",
"singularValues",
"[",
"i",
"]",
";",
"if",
"(",
"val",
"<",
"0",
")",
"{",
"singularValues",
"[",
"i",
"]",
"=",
"-",
"val",
";",
"if",
"(",
"computeU",
")",
"{",
"// compute the results of multiplying it by an element of -1 at this location in",
"// a diagonal matrix.",
"int",
"start",
"=",
"i",
"*",
"Ut",
".",
"numCols",
";",
"int",
"stop",
"=",
"start",
"+",
"Ut",
".",
"numCols",
";",
"for",
"(",
"int",
"j",
"=",
"start",
";",
"j",
"<",
"stop",
";",
"j",
"++",
")",
"{",
"Ut",
".",
"data",
"[",
"j",
"]",
"=",
"-",
"Ut",
".",
"data",
"[",
"j",
"]",
";",
"}",
"}",
"}",
"}",
"}"
] | With the QR algorithm it is possible for the found singular values to be native. This
makes them all positive by multiplying it by a diagonal matrix that has | [
"With",
"the",
"QR",
"algorithm",
"it",
"is",
"possible",
"for",
"the",
"found",
"singular",
"values",
"to",
"be",
"native",
".",
"This",
"makes",
"them",
"all",
"positive",
"by",
"multiplying",
"it",
"by",
"a",
"diagonal",
"matrix",
"that",
"has"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_Ultimate.java#L279-L301 |
162,384 | lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.fit | public void fit( double samplePoints[] , double[] observations ) {
// Create a copy of the observations and put it into a matrix
y.reshape(observations.length,1,false);
System.arraycopy(observations,0, y.data,0,observations.length);
// reshape the matrix to avoid unnecessarily declaring new memory
// save values is set to false since its old values don't matter
A.reshape(y.numRows, coef.numRows,false);
// set up the A matrix
for( int i = 0; i < observations.length; i++ ) {
double obs = 1;
for( int j = 0; j < coef.numRows; j++ ) {
A.set(i,j,obs);
obs *= samplePoints[i];
}
}
// process the A matrix and see if it failed
if( !solver.setA(A) )
throw new RuntimeException("Solver failed");
// solver the the coefficients
solver.solve(y,coef);
} | java | public void fit( double samplePoints[] , double[] observations ) {
// Create a copy of the observations and put it into a matrix
y.reshape(observations.length,1,false);
System.arraycopy(observations,0, y.data,0,observations.length);
// reshape the matrix to avoid unnecessarily declaring new memory
// save values is set to false since its old values don't matter
A.reshape(y.numRows, coef.numRows,false);
// set up the A matrix
for( int i = 0; i < observations.length; i++ ) {
double obs = 1;
for( int j = 0; j < coef.numRows; j++ ) {
A.set(i,j,obs);
obs *= samplePoints[i];
}
}
// process the A matrix and see if it failed
if( !solver.setA(A) )
throw new RuntimeException("Solver failed");
// solver the the coefficients
solver.solve(y,coef);
} | [
"public",
"void",
"fit",
"(",
"double",
"samplePoints",
"[",
"]",
",",
"double",
"[",
"]",
"observations",
")",
"{",
"// Create a copy of the observations and put it into a matrix",
"y",
".",
"reshape",
"(",
"observations",
".",
"length",
",",
"1",
",",
"false",
")",
";",
"System",
".",
"arraycopy",
"(",
"observations",
",",
"0",
",",
"y",
".",
"data",
",",
"0",
",",
"observations",
".",
"length",
")",
";",
"// reshape the matrix to avoid unnecessarily declaring new memory",
"// save values is set to false since its old values don't matter",
"A",
".",
"reshape",
"(",
"y",
".",
"numRows",
",",
"coef",
".",
"numRows",
",",
"false",
")",
";",
"// set up the A matrix",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"observations",
".",
"length",
";",
"i",
"++",
")",
"{",
"double",
"obs",
"=",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"coef",
".",
"numRows",
";",
"j",
"++",
")",
"{",
"A",
".",
"set",
"(",
"i",
",",
"j",
",",
"obs",
")",
";",
"obs",
"*=",
"samplePoints",
"[",
"i",
"]",
";",
"}",
"}",
"// process the A matrix and see if it failed",
"if",
"(",
"!",
"solver",
".",
"setA",
"(",
"A",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Solver failed\"",
")",
";",
"// solver the the coefficients",
"solver",
".",
"solve",
"(",
"y",
",",
"coef",
")",
";",
"}"
] | Computes the best fit set of polynomial coefficients to the provided observations.
@param samplePoints where the observations were sampled.
@param observations A set of observations. | [
"Computes",
"the",
"best",
"fit",
"set",
"of",
"polynomial",
"coefficients",
"to",
"the",
"provided",
"observations",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L82-L108 |
162,385 | lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.removeWorstFit | public void removeWorstFit() {
// find the observation with the most error
int worstIndex=-1;
double worstError = -1;
for( int i = 0; i < y.numRows; i++ ) {
double predictedObs = 0;
for( int j = 0; j < coef.numRows; j++ ) {
predictedObs += A.get(i,j)*coef.get(j,0);
}
double error = Math.abs(predictedObs- y.get(i,0));
if( error > worstError ) {
worstError = error;
worstIndex = i;
}
}
// nothing left to remove, so just return
if( worstIndex == -1 )
return;
// remove that observation
removeObservation(worstIndex);
// update A
solver.removeRowFromA(worstIndex);
// solve for the parameters again
solver.solve(y,coef);
} | java | public void removeWorstFit() {
// find the observation with the most error
int worstIndex=-1;
double worstError = -1;
for( int i = 0; i < y.numRows; i++ ) {
double predictedObs = 0;
for( int j = 0; j < coef.numRows; j++ ) {
predictedObs += A.get(i,j)*coef.get(j,0);
}
double error = Math.abs(predictedObs- y.get(i,0));
if( error > worstError ) {
worstError = error;
worstIndex = i;
}
}
// nothing left to remove, so just return
if( worstIndex == -1 )
return;
// remove that observation
removeObservation(worstIndex);
// update A
solver.removeRowFromA(worstIndex);
// solve for the parameters again
solver.solve(y,coef);
} | [
"public",
"void",
"removeWorstFit",
"(",
")",
"{",
"// find the observation with the most error",
"int",
"worstIndex",
"=",
"-",
"1",
";",
"double",
"worstError",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"y",
".",
"numRows",
";",
"i",
"++",
")",
"{",
"double",
"predictedObs",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"coef",
".",
"numRows",
";",
"j",
"++",
")",
"{",
"predictedObs",
"+=",
"A",
".",
"get",
"(",
"i",
",",
"j",
")",
"*",
"coef",
".",
"get",
"(",
"j",
",",
"0",
")",
";",
"}",
"double",
"error",
"=",
"Math",
".",
"abs",
"(",
"predictedObs",
"-",
"y",
".",
"get",
"(",
"i",
",",
"0",
")",
")",
";",
"if",
"(",
"error",
">",
"worstError",
")",
"{",
"worstError",
"=",
"error",
";",
"worstIndex",
"=",
"i",
";",
"}",
"}",
"// nothing left to remove, so just return",
"if",
"(",
"worstIndex",
"==",
"-",
"1",
")",
"return",
";",
"// remove that observation",
"removeObservation",
"(",
"worstIndex",
")",
";",
"// update A",
"solver",
".",
"removeRowFromA",
"(",
"worstIndex",
")",
";",
"// solve for the parameters again",
"solver",
".",
"solve",
"(",
"y",
",",
"coef",
")",
";",
"}"
] | Removes the observation that fits the model the worst and recomputes the coefficients.
This is done efficiently by using an adjustable solver. Often times the elements with
the largest errors are outliers and not part of the system being modeled. By removing them
a more accurate set of coefficients can be computed. | [
"Removes",
"the",
"observation",
"that",
"fits",
"the",
"model",
"the",
"worst",
"and",
"recomputes",
"the",
"coefficients",
".",
"This",
"is",
"done",
"efficiently",
"by",
"using",
"an",
"adjustable",
"solver",
".",
"Often",
"times",
"the",
"elements",
"with",
"the",
"largest",
"errors",
"are",
"outliers",
"and",
"not",
"part",
"of",
"the",
"system",
"being",
"modeled",
".",
"By",
"removing",
"them",
"a",
"more",
"accurate",
"set",
"of",
"coefficients",
"can",
"be",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L116-L148 |
162,386 | lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.removeObservation | private void removeObservation( int index ) {
final int N = y.numRows-1;
final double d[] = y.data;
// shift
for( int i = index; i < N; i++ ) {
d[i] = d[i+1];
}
y.numRows--;
} | java | private void removeObservation( int index ) {
final int N = y.numRows-1;
final double d[] = y.data;
// shift
for( int i = index; i < N; i++ ) {
d[i] = d[i+1];
}
y.numRows--;
} | [
"private",
"void",
"removeObservation",
"(",
"int",
"index",
")",
"{",
"final",
"int",
"N",
"=",
"y",
".",
"numRows",
"-",
"1",
";",
"final",
"double",
"d",
"[",
"]",
"=",
"y",
".",
"data",
";",
"// shift",
"for",
"(",
"int",
"i",
"=",
"index",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"d",
"[",
"i",
"]",
"=",
"d",
"[",
"i",
"+",
"1",
"]",
";",
"}",
"y",
".",
"numRows",
"--",
";",
"}"
] | Removes an element from the observation matrix.
@param index which element is to be removed | [
"Removes",
"an",
"element",
"from",
"the",
"observation",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L155-L164 |
162,387 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/SpecializedOps_ZDRM.java | SpecializedOps_ZDRM.householderVector | public static ZMatrixRMaj householderVector(ZMatrixRMaj x ) {
ZMatrixRMaj u = x.copy();
double max = CommonOps_ZDRM.elementMaxAbs(u);
CommonOps_ZDRM.elementDivide(u, max, 0, u);
double nx = NormOps_ZDRM.normF(u);
Complex_F64 c = new Complex_F64();
u.get(0,0,c);
double realTau,imagTau;
if( c.getMagnitude() == 0 ) {
realTau = nx;
imagTau = 0;
} else {
realTau = c.real/c.getMagnitude()*nx;
imagTau = c.imaginary/c.getMagnitude()*nx;
}
u.set(0,0,c.real + realTau,c.imaginary + imagTau);
CommonOps_ZDRM.elementDivide(u,u.getReal(0,0),u.getImag(0,0),u);
return u;
} | java | public static ZMatrixRMaj householderVector(ZMatrixRMaj x ) {
ZMatrixRMaj u = x.copy();
double max = CommonOps_ZDRM.elementMaxAbs(u);
CommonOps_ZDRM.elementDivide(u, max, 0, u);
double nx = NormOps_ZDRM.normF(u);
Complex_F64 c = new Complex_F64();
u.get(0,0,c);
double realTau,imagTau;
if( c.getMagnitude() == 0 ) {
realTau = nx;
imagTau = 0;
} else {
realTau = c.real/c.getMagnitude()*nx;
imagTau = c.imaginary/c.getMagnitude()*nx;
}
u.set(0,0,c.real + realTau,c.imaginary + imagTau);
CommonOps_ZDRM.elementDivide(u,u.getReal(0,0),u.getImag(0,0),u);
return u;
} | [
"public",
"static",
"ZMatrixRMaj",
"householderVector",
"(",
"ZMatrixRMaj",
"x",
")",
"{",
"ZMatrixRMaj",
"u",
"=",
"x",
".",
"copy",
"(",
")",
";",
"double",
"max",
"=",
"CommonOps_ZDRM",
".",
"elementMaxAbs",
"(",
"u",
")",
";",
"CommonOps_ZDRM",
".",
"elementDivide",
"(",
"u",
",",
"max",
",",
"0",
",",
"u",
")",
";",
"double",
"nx",
"=",
"NormOps_ZDRM",
".",
"normF",
"(",
"u",
")",
";",
"Complex_F64",
"c",
"=",
"new",
"Complex_F64",
"(",
")",
";",
"u",
".",
"get",
"(",
"0",
",",
"0",
",",
"c",
")",
";",
"double",
"realTau",
",",
"imagTau",
";",
"if",
"(",
"c",
".",
"getMagnitude",
"(",
")",
"==",
"0",
")",
"{",
"realTau",
"=",
"nx",
";",
"imagTau",
"=",
"0",
";",
"}",
"else",
"{",
"realTau",
"=",
"c",
".",
"real",
"/",
"c",
".",
"getMagnitude",
"(",
")",
"*",
"nx",
";",
"imagTau",
"=",
"c",
".",
"imaginary",
"/",
"c",
".",
"getMagnitude",
"(",
")",
"*",
"nx",
";",
"}",
"u",
".",
"set",
"(",
"0",
",",
"0",
",",
"c",
".",
"real",
"+",
"realTau",
",",
"c",
".",
"imaginary",
"+",
"imagTau",
")",
";",
"CommonOps_ZDRM",
".",
"elementDivide",
"(",
"u",
",",
"u",
".",
"getReal",
"(",
"0",
",",
"0",
")",
",",
"u",
".",
"getImag",
"(",
"0",
",",
"0",
")",
",",
"u",
")",
";",
"return",
"u",
";",
"}"
] | Computes the householder vector used in QR decomposition.
u = x / max(x)
u(0) = u(0) + |u|
u = u / u(0)
@param x Input vector. Unmodified.
@return The found householder reflector vector | [
"Computes",
"the",
"householder",
"vector",
"used",
"in",
"QR",
"decomposition",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/SpecializedOps_ZDRM.java#L217-L242 |
162,388 | lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/hessenberg/HessenbergSimilarDecomposition_ZDRM.java | HessenbergSimilarDecomposition_ZDRM.decompose | @Override
public boolean decompose( ZMatrixRMaj A )
{
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be square.");
if( A.numRows <= 0 )
return false;
QH = A;
N = A.numCols;
if( b.length < N*2 ) {
b = new double[ N*2 ];
gammas = new double[ N ];
u = new double[ N*2 ];
}
return _decompose();
} | java | @Override
public boolean decompose( ZMatrixRMaj A )
{
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be square.");
if( A.numRows <= 0 )
return false;
QH = A;
N = A.numCols;
if( b.length < N*2 ) {
b = new double[ N*2 ];
gammas = new double[ N ];
u = new double[ N*2 ];
}
return _decompose();
} | [
"@",
"Override",
"public",
"boolean",
"decompose",
"(",
"ZMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A must be square.\"",
")",
";",
"if",
"(",
"A",
".",
"numRows",
"<=",
"0",
")",
"return",
"false",
";",
"QH",
"=",
"A",
";",
"N",
"=",
"A",
".",
"numCols",
";",
"if",
"(",
"b",
".",
"length",
"<",
"N",
"*",
"2",
")",
"{",
"b",
"=",
"new",
"double",
"[",
"N",
"*",
"2",
"]",
";",
"gammas",
"=",
"new",
"double",
"[",
"N",
"]",
";",
"u",
"=",
"new",
"double",
"[",
"N",
"*",
"2",
"]",
";",
"}",
"return",
"_decompose",
"(",
")",
";",
"}"
] | Computes the decomposition of the provided matrix. If no errors are detected then true is returned,
false otherwise.
@param A The matrix that is being decomposed. Not modified.
@return If it detects any errors or not. | [
"Computes",
"the",
"decomposition",
"of",
"the",
"provided",
"matrix",
".",
"If",
"no",
"errors",
"are",
"detected",
"then",
"true",
"is",
"returned",
"false",
"otherwise",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/hessenberg/HessenbergSimilarDecomposition_ZDRM.java#L86-L104 |
162,389 | lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/AdjLinearSolverQr_DDRM.java | AdjLinearSolverQr_DDRM.getA | @Override
public DMatrixRMaj getA() {
if( A.data.length < numRows*numCols ) {
A = new DMatrixRMaj(numRows,numCols);
}
A.reshape(numRows,numCols, false);
CommonOps_DDRM.mult(Q,R,A);
return A;
} | java | @Override
public DMatrixRMaj getA() {
if( A.data.length < numRows*numCols ) {
A = new DMatrixRMaj(numRows,numCols);
}
A.reshape(numRows,numCols, false);
CommonOps_DDRM.mult(Q,R,A);
return A;
} | [
"@",
"Override",
"public",
"DMatrixRMaj",
"getA",
"(",
")",
"{",
"if",
"(",
"A",
".",
"data",
".",
"length",
"<",
"numRows",
"*",
"numCols",
")",
"{",
"A",
"=",
"new",
"DMatrixRMaj",
"(",
"numRows",
",",
"numCols",
")",
";",
"}",
"A",
".",
"reshape",
"(",
"numRows",
",",
"numCols",
",",
"false",
")",
";",
"CommonOps_DDRM",
".",
"mult",
"(",
"Q",
",",
"R",
",",
"A",
")",
";",
"return",
"A",
";",
"}"
] | Compute the A matrix from the Q and R matrices.
@return The A matrix. | [
"Compute",
"the",
"A",
"matrix",
"from",
"the",
"Q",
"and",
"R",
"matrices",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/AdjLinearSolverQr_DDRM.java#L60-L69 |
162,390 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( T a ) {
if( a.getType() == getType() )
mat.set(a.getMatrix());
else {
setMatrix(a.mat.copy());
}
} | java | public void set( T a ) {
if( a.getType() == getType() )
mat.set(a.getMatrix());
else {
setMatrix(a.mat.copy());
}
} | [
"public",
"void",
"set",
"(",
"T",
"a",
")",
"{",
"if",
"(",
"a",
".",
"getType",
"(",
")",
"==",
"getType",
"(",
")",
")",
"mat",
".",
"set",
"(",
"a",
".",
"getMatrix",
"(",
")",
")",
";",
"else",
"{",
"setMatrix",
"(",
"a",
".",
"mat",
".",
"copy",
"(",
")",
")",
";",
"}",
"}"
] | Sets the elements in this matrix to be equal to the elements in the passed in matrix.
Both matrix must have the same dimension.
@param a The matrix whose value this matrix is being set to. | [
"Sets",
"the",
"elements",
"in",
"this",
"matrix",
"to",
"be",
"equal",
"to",
"the",
"elements",
"in",
"the",
"passed",
"in",
"matrix",
".",
"Both",
"matrix",
"must",
"have",
"the",
"same",
"dimension",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L489-L495 |
162,391 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int row , int col , double value ) {
ops.set(mat, row, col, value);
} | java | public void set( int row , int col , double value ) {
ops.set(mat, row, col, value);
} | [
"public",
"void",
"set",
"(",
"int",
"row",
",",
"int",
"col",
",",
"double",
"value",
")",
"{",
"ops",
".",
"set",
"(",
"mat",
",",
"row",
",",
"col",
",",
"value",
")",
";",
"}"
] | Assigns the element in the Matrix to the specified value. Performs a bounds check to make sure
the requested element is part of the matrix.
@param row The row of the element.
@param col The column of the element.
@param value The element's new value. | [
"Assigns",
"the",
"element",
"in",
"the",
"Matrix",
"to",
"the",
"specified",
"value",
".",
"Performs",
"a",
"bounds",
"check",
"to",
"make",
"sure",
"the",
"requested",
"element",
"is",
"part",
"of",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L615-L617 |
162,392 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int index , double value ) {
if( mat.getType() == MatrixType.DDRM ) {
((DMatrixRMaj) mat).set(index, value);
} else if( mat.getType() == MatrixType.FDRM ) {
((FMatrixRMaj) mat).set(index, (float)value);
} else {
throw new RuntimeException("Not supported yet for this matrix type");
}
} | java | public void set( int index , double value ) {
if( mat.getType() == MatrixType.DDRM ) {
((DMatrixRMaj) mat).set(index, value);
} else if( mat.getType() == MatrixType.FDRM ) {
((FMatrixRMaj) mat).set(index, (float)value);
} else {
throw new RuntimeException("Not supported yet for this matrix type");
}
} | [
"public",
"void",
"set",
"(",
"int",
"index",
",",
"double",
"value",
")",
"{",
"if",
"(",
"mat",
".",
"getType",
"(",
")",
"==",
"MatrixType",
".",
"DDRM",
")",
"{",
"(",
"(",
"DMatrixRMaj",
")",
"mat",
")",
".",
"set",
"(",
"index",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"mat",
".",
"getType",
"(",
")",
"==",
"MatrixType",
".",
"FDRM",
")",
"{",
"(",
"(",
"FMatrixRMaj",
")",
"mat",
")",
".",
"set",
"(",
"index",
",",
"(",
"float",
")",
"value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Not supported yet for this matrix type\"",
")",
";",
"}",
"}"
] | Assigns an element a value based on its index in the internal array..
@param index The matrix element that is being assigned a value.
@param value The element's new value. | [
"Assigns",
"an",
"element",
"a",
"value",
"based",
"on",
"its",
"index",
"in",
"the",
"internal",
"array",
".."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L625-L633 |
162,393 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int row , int col , double real , double imaginary ) {
if( imaginary == 0 ) {
set(row,col,real);
} else {
ops.set(mat,row,col, real, imaginary);
}
} | java | public void set( int row , int col , double real , double imaginary ) {
if( imaginary == 0 ) {
set(row,col,real);
} else {
ops.set(mat,row,col, real, imaginary);
}
} | [
"public",
"void",
"set",
"(",
"int",
"row",
",",
"int",
"col",
",",
"double",
"real",
",",
"double",
"imaginary",
")",
"{",
"if",
"(",
"imaginary",
"==",
"0",
")",
"{",
"set",
"(",
"row",
",",
"col",
",",
"real",
")",
";",
"}",
"else",
"{",
"ops",
".",
"set",
"(",
"mat",
",",
"row",
",",
"col",
",",
"real",
",",
"imaginary",
")",
";",
"}",
"}"
] | Used to set the complex value of a matrix element.
@param row The row of the element.
@param col The column of the element.
@param real Real component of assigned value
@param imaginary Imaginary component of assigned value | [
"Used",
"to",
"set",
"the",
"complex",
"value",
"of",
"a",
"matrix",
"element",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L642-L648 |
162,394 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.get | public double get( int index ) {
MatrixType type = mat.getType();
if( type.isReal()) {
if (type.getBits() == 64) {
return ((DMatrixRMaj) mat).data[index];
} else {
return ((FMatrixRMaj) mat).data[index];
}
} else {
throw new IllegalArgumentException("Complex matrix. Call get(int,Complex64F) instead");
}
} | java | public double get( int index ) {
MatrixType type = mat.getType();
if( type.isReal()) {
if (type.getBits() == 64) {
return ((DMatrixRMaj) mat).data[index];
} else {
return ((FMatrixRMaj) mat).data[index];
}
} else {
throw new IllegalArgumentException("Complex matrix. Call get(int,Complex64F) instead");
}
} | [
"public",
"double",
"get",
"(",
"int",
"index",
")",
"{",
"MatrixType",
"type",
"=",
"mat",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
".",
"isReal",
"(",
")",
")",
"{",
"if",
"(",
"type",
".",
"getBits",
"(",
")",
"==",
"64",
")",
"{",
"return",
"(",
"(",
"DMatrixRMaj",
")",
"mat",
")",
".",
"data",
"[",
"index",
"]",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"FMatrixRMaj",
")",
"mat",
")",
".",
"data",
"[",
"index",
"]",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Complex matrix. Call get(int,Complex64F) instead\"",
")",
";",
"}",
"}"
] | Returns the value of the matrix at the specified index of the 1D row major array.
@see DMatrixRMaj#get(int)
@param index The element's index whose value is to be returned
@return The value of the specified element. | [
"Returns",
"the",
"value",
"of",
"the",
"matrix",
"at",
"the",
"specified",
"index",
"of",
"the",
"1D",
"row",
"major",
"array",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L702-L714 |
162,395 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.get | public void get( int row , int col , Complex_F64 output ) {
ops.get(mat,row,col,output);
} | java | public void get( int row , int col , Complex_F64 output ) {
ops.get(mat,row,col,output);
} | [
"public",
"void",
"get",
"(",
"int",
"row",
",",
"int",
"col",
",",
"Complex_F64",
"output",
")",
"{",
"ops",
".",
"get",
"(",
"mat",
",",
"row",
",",
"col",
",",
"output",
")",
";",
"}"
] | Used to get the complex value of a matrix element.
@param row The row of the element.
@param col The column of the element.
@param output Storage for the value | [
"Used",
"to",
"get",
"the",
"complex",
"value",
"of",
"a",
"matrix",
"element",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L722-L724 |
162,396 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.copy | public T copy() {
T ret = createLike();
ret.getMatrix().set(this.getMatrix());
return ret;
} | java | public T copy() {
T ret = createLike();
ret.getMatrix().set(this.getMatrix());
return ret;
} | [
"public",
"T",
"copy",
"(",
")",
"{",
"T",
"ret",
"=",
"createLike",
"(",
")",
";",
"ret",
".",
"getMatrix",
"(",
")",
".",
"set",
"(",
"this",
".",
"getMatrix",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] | Creates and returns a matrix which is idential to this one.
@return A new identical matrix. | [
"Creates",
"and",
"returns",
"a",
"matrix",
"which",
"is",
"idential",
"to",
"this",
"one",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L761-L765 |
162,397 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.isIdentical | public boolean isIdentical(T a, double tol) {
if( a.getType() != getType() )
return false;
return ops.isIdentical(mat,a.mat,tol);
} | java | public boolean isIdentical(T a, double tol) {
if( a.getType() != getType() )
return false;
return ops.isIdentical(mat,a.mat,tol);
} | [
"public",
"boolean",
"isIdentical",
"(",
"T",
"a",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"a",
".",
"getType",
"(",
")",
"!=",
"getType",
"(",
")",
")",
"return",
"false",
";",
"return",
"ops",
".",
"isIdentical",
"(",
"mat",
",",
"a",
".",
"mat",
",",
"tol",
")",
";",
"}"
] | Checks to see if matrix 'a' is the same as this matrix within the specified
tolerance.
@param a The matrix it is being compared against.
@param tol How similar they must be to be equals.
@return If they are equal within tolerance of each other. | [
"Checks",
"to",
"see",
"if",
"matrix",
"a",
"is",
"the",
"same",
"as",
"this",
"matrix",
"within",
"the",
"specified",
"tolerance",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L904-L908 |
162,398 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.isInBounds | public boolean isInBounds(int row, int col) {
return row >= 0 && col >= 0 && row < mat.getNumRows() && col < mat.getNumCols();
} | java | public boolean isInBounds(int row, int col) {
return row >= 0 && col >= 0 && row < mat.getNumRows() && col < mat.getNumCols();
} | [
"public",
"boolean",
"isInBounds",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"return",
"row",
">=",
"0",
"&&",
"col",
">=",
"0",
"&&",
"row",
"<",
"mat",
".",
"getNumRows",
"(",
")",
"&&",
"col",
"<",
"mat",
".",
"getNumCols",
"(",
")",
";",
"}"
] | Returns true of the specified matrix element is valid element inside this matrix.
@param row Row index.
@param col Column index.
@return true if it is a valid element in the matrix. | [
"Returns",
"true",
"of",
"the",
"specified",
"matrix",
"element",
"is",
"valid",
"element",
"inside",
"this",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L1331-L1333 |
162,399 | lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.convertToSparse | public void convertToSparse() {
switch ( mat.getType() ) {
case DDRM: {
DMatrixSparseCSC m = new DMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case FDRM: {
FMatrixSparseCSC m = new FMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case DSCC:
case FSCC:
break;
default:
throw new RuntimeException("Conversion not supported!");
}
} | java | public void convertToSparse() {
switch ( mat.getType() ) {
case DDRM: {
DMatrixSparseCSC m = new DMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case FDRM: {
FMatrixSparseCSC m = new FMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case DSCC:
case FSCC:
break;
default:
throw new RuntimeException("Conversion not supported!");
}
} | [
"public",
"void",
"convertToSparse",
"(",
")",
"{",
"switch",
"(",
"mat",
".",
"getType",
"(",
")",
")",
"{",
"case",
"DDRM",
":",
"{",
"DMatrixSparseCSC",
"m",
"=",
"new",
"DMatrixSparseCSC",
"(",
"mat",
".",
"getNumRows",
"(",
")",
",",
"mat",
".",
"getNumCols",
"(",
")",
")",
";",
"ConvertDMatrixStruct",
".",
"convert",
"(",
"(",
"DMatrixRMaj",
")",
"mat",
",",
"m",
",",
"0",
")",
";",
"setMatrix",
"(",
"m",
")",
";",
"}",
"break",
";",
"case",
"FDRM",
":",
"{",
"FMatrixSparseCSC",
"m",
"=",
"new",
"FMatrixSparseCSC",
"(",
"mat",
".",
"getNumRows",
"(",
")",
",",
"mat",
".",
"getNumCols",
"(",
")",
")",
";",
"ConvertFMatrixStruct",
".",
"convert",
"(",
"(",
"FMatrixRMaj",
")",
"mat",
",",
"m",
",",
"0",
")",
";",
"setMatrix",
"(",
"m",
")",
";",
"}",
"break",
";",
"case",
"DSCC",
":",
"case",
"FSCC",
":",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Conversion not supported!\"",
")",
";",
"}",
"}"
] | Switches from a dense to sparse matrix | [
"Switches",
"from",
"a",
"dense",
"to",
"sparse",
"matrix"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L1501-L1520 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.