code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected static String getAttribute(Node node, String name, boolean required) {
NamedNodeMap attributes = node.getAttributes();
Node idNode = attributes.getNamedItem(name);
if (idNode == null) {
if (required) {
throw new IllegalArgumentException(toPath(node) + "... | java |
protected static Iterable<Node> evaluate(Node element, XPathExpression expression,
boolean detatch) throws XPathExpressionException {
final NodeList nodeList = (NodeList) expression.evaluate(element, XPathConstants.NODESET);
return new Iterable<Node>() {
@Override
... | java |
public String getProperty(String key, String defaultValue) {
String value = resolver.get(key);
return (value == null) ? defaultValue : value;
} | java |
public static ConfigurationOption newConfiguration(String pid) {
return new org.ops4j.pax.exam.cm.internal.ConfigurationProvisionOption(pid, new HashMap<String, Object>());
} | java |
public static ConfigurationOption overrideConfiguration(String pid) {
return new org.ops4j.pax.exam.cm.internal.ConfigurationProvisionOption(pid, new HashMap<String, Object>()).override(true)
.create(false);
} | java |
public static ConfigurationOption factoryConfiguration(String pid) {
return new org.ops4j.pax.exam.cm.internal.ConfigurationProvisionOption(pid, new HashMap<String, Object>()).factory(true);
} | java |
public static Option configurationFolder(File folder, String extension) {
if (!folder.exists()) {
throw new TestContainerException("folder " + folder + " does not exits");
}
List<Option> options = new ArrayList<Option>();
File[] files = folder.listFiles();
for (File ... | java |
private BundleContext getBundleContext(Bundle bundle, long timeout) {
long endTime = System.currentTimeMillis() + timeout;
BundleContext bc = null;
while (bc == null) {
bc = bundle.getBundleContext();
if (bc == null) {
if (System.currentTimeMillis() >= end... | java |
@Produces
@RequestScoped
public EntityManager getEntityManager(EntityManagerFactory emf) {
log.debug("producing EntityManager");
return emf.createEntityManager();
} | java |
public TestProbeBuilder createProbeBuilder(Object testClassInstance) throws IOException,
ExamConfigurationException {
if (defaultProbeBuilder == null) {
defaultProbeBuilder = system.createProbe();
}
TestProbeBuilder probeBuilder = overwriteWithUserDefinition(currentTestClass,... | java |
public static void streamCopy(final InputStream in, final FileChannel out,
final ProgressBar progressBar) throws IOException {
NullArgumentException.validateNotNull(in, "Input stream");
NullArgumentException.validateNotNull(out, "Output stream");
final long start = System.currentTimeMill... | java |
public static void streamCopy(final URL url, final FileChannel out,
final ProgressBar progressBar) throws IOException {
NullArgumentException.validateNotNull(url, "URL");
InputStream is = null;
try {
is = url.openStream();
streamCopy(is, out, progressBar);
... | java |
public void close() throws IOException {
if (jarOutputStream != null) {
jarOutputStream.close();
}
else if (os != null) {
os.close();
}
} | java |
private void addDirectory(File root, File directory, String targetPath, ZipOutputStream zos) throws IOException {
String prefix = targetPath;
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
// directory entries are required, or else bundle classpath may be
... | java |
private void addFile(File root, File file, String prefix, ZipOutputStream zos) throws IOException {
FileInputStream fis = new FileInputStream(file);
ZipEntry jarEntry = new ZipEntry(prefix + normalizePath(root, file));
zos.putNextEntry(jarEntry);
StreamUtils.copyStream(fis, zos, false);
... | java |
private String normalizePath(File root, File file) {
String relativePath = file.getPath().substring(root.getPath().length() + 1);
String path = relativePath.replaceAll("\\" + File.separator, "/");
return path;
} | java |
public void copyBootClasspathLibraries() throws IOException {
BootClasspathLibraryOption[] bootClasspathLibraryOptions = subsystem
.getOptions(BootClasspathLibraryOption.class);
for (BootClasspathLibraryOption bootClasspathLibraryOption : bootClasspathLibraryOptions) {
UrlReferen... | java |
public void copyReferencedArtifactsToDeployFolder() {
File deploy = new File(karafBase, "deploy");
String[] fileEndings = new String[] { "jar", "war", "zip", "kar", "xml" };
ProvisionOption<?>[] options = subsystem.getOptions(ProvisionOption.class);
for (ProvisionOption<?> option : optio... | java |
public KarafFeaturesOption getDependenciesFeature() {
if (subsystem == null) {
return null;
}
try {
File featuresXmlFile = new File(karafBase, "test-dependencies.xml");
Writer wr = new OutputStreamWriter(new FileOutputStream(featuresXmlFile), "UTF-8");
... | java |
static void writeDependenciesFeature(Writer writer, ProvisionOption<?>... provisionOptions) {
XMLOutputFactory xof = XMLOutputFactory.newInstance();
xof.setProperty("javax.xml.stream.isRepairingNamespaces", true);
XMLStreamWriter sw = null;
try {
sw = xof.createXMLStreamWrit... | java |
public static void extract(URL sourceURL, File targetFolder)
throws IOException {
if (sourceURL.getProtocol().equals("file")) {
if (sourceURL.getFile().indexOf(".zip") > 0) {
extractZipDistribution(sourceURL, targetFolder);
}
else if (sourceURL.getFile... | java |
public CommandLineBuilder append(final String[] segments) {
if (segments != null && segments.length > 0) {
final String[] command = new String[commandLine.length + segments.length];
System.arraycopy(commandLine, 0, command, 0, commandLine.length);
System.arraycopy(segments, 0... | java |
public CommandLineBuilder append(final String segment) {
if (segment != null && !segment.isEmpty()) {
return append(new String[]{segment});
}
return this;
} | java |
public static String getArtifactVersion(final String groupId, final String artifactId) {
final Properties dependencies = new Properties();
InputStream depInputStream = null;
try {
String depFilePath = "META-INF/maven/dependencies.properties";
URL fileURL = MavenUtils.clas... | java |
public static MavenArtifactUrlReference.VersionResolver asInProject() {
return new MavenArtifactUrlReference.VersionResolver() {
@Override
public String getVersion(final String groupId, final String artifactId) {
return getArtifactVersion(groupId, artifactId);
... | java |
public URI buildWar() {
if (option.getName() == null) {
option.name(UUID.randomUUID().toString());
}
processClassPath();
try {
File webResourceDir = getWebResourceDir();
File probeWar = new File(tempDir, option.getName() + ".war");
ZipBuild... | java |
private static void daxpy(double constant, double vector1[], double vector2[]) {
if (constant == 0) return;
assert vector1.length == vector2.length;
for (int i = 0; i < vector1.length; i++) {
vector2[i] += constant * vector1[i];
}
} | java |
private static double dot(double vector1[], double vector2[]) {
double product = 0;
assert vector1.length == vector2.length;
for (int i = 0; i < vector1.length; i++) {
product += vector1[i] * vector2[i];
}
return product;
} | java |
private static double euclideanNorm(double vector[]) {
int n = vector.length;
if (n < 1) {
return 0;
}
if (n == 1) {
return Math.abs(vector[0]);
}
// this algorithm is (often) more accurate than just summing up the squares and taking the square... | java |
private static void scale(double constant, double vector[]) {
if (constant == 1.0) return;
for (int i = 0; i < vector.length; i++) {
vector[i] *= constant;
}
} | java |
@SuppressWarnings("unused") // Public API
public void setAutoScaleEnabled(boolean isAutoScaleEnabled) {
this.isAutoScaleEnabled = isAutoScaleEnabled;
for (int i = 0, size = foldableItemsMap.size(); i < size; i++) {
foldableItemsMap.valueAt(i).setAutoScaleEnabled(isAutoScaleEnabled);
... | java |
public void setFoldRotation(float rotation) {
foldRotation = rotation;
topPart.applyFoldRotation(rotation);
bottomPart.applyFoldRotation(rotation);
setInTransformation(rotation != 0f);
scaleFactor = 1f;
if (isAutoScaleEnabled && width > 0) {
double sin = M... | java |
public void setRollingDistance(float distance) {
final float scaleY = scale * scaleFactor * scaleFactorY;
topPart.applyRollingDistance(distance, scaleY);
bottomPart.applyRollingDistance(distance, scaleY);
} | java |
public void unfold(View coverView, View detailsView) {
if (this.coverView == coverView && this.detailsView == detailsView) {
scrollToPosition(1); // Starting unfold animation
return;
}
if ((this.coverView != null && this.coverView != coverView)
|| (this.d... | java |
public BytesWritable evaluate(BytesWritable geomref) {
if (geomref == null || geomref.getLength() == 0){
LogUtils.Log_ArgumentsNull(LOG);
return null;
}
OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
if (ogcGeometry == null){
LogUtils.Log_ArgumentsNull(LOG);
return null;
... | java |
public long getId(double x, double y) {
double down = (extentMax - y) / binSize;
double over = (x - extentMin) / binSize;
return ((long)down * numCols) + (long)over;
} | java |
public void queryEnvelope(long binId, Envelope envelope) {
long down = binId / numCols;
long over = binId % numCols;
double xmin = extentMin + (over * binSize);
double xmax = xmin + binSize;
double ymax = extentMax - (down * binSize);
double ymin = ymax - binSize;
envelope.setCoords(xmin, y... | java |
public void queryEnvelope(double x, double y, Envelope envelope) {
double down = (extentMax - y) / binSize;
double over = (x - extentMin) / binSize;
double xmin = extentMin + (over * binSize);
double xmax = xmin + binSize;
double ymax = extentMax - (down * binSize);
double ymin = ymax - binSize;
... | java |
@Override
public boolean next(LongWritable key, Text value) throws IOException {
JsonToken token;
// first call to nextKeyValue() so we need to create the parser and move to the
// feature array
if (parser == null) {
parser = new JsonFactory().createJsonParser(inputStream);
parser.setCodec(new Obj... | java |
public static void Log_SRIDMismatch(Log logger, BytesWritable geomref1, BytesWritable geomref2){
logger.error(String.format(messages[MSG_SRID_MISMATCH], GeometryUtils.getWKID(geomref1), GeometryUtils.getWKID(geomref2)));
} | java |
public static int getWKID(BytesWritable geomref){
ByteBuffer bb = ByteBuffer.wrap(geomref.getBytes());
return bb.getInt(0);
} | java |
protected boolean moveToRecordStart() throws IOException {
int next = 0;
long resetPosition = readerPosition;
// The case of split point exactly at whitespace between records, is
// handled by forcing it to the split following, in the interest of
// better balancing the splits, by consuming the whitespace in... | java |
@Override public float getProgress() throws IOException {
if (reachedEnd)
return 1;
else {
final long filePos = in.position();
final long fileEnd = virtualEnd >>> 16;
// Add 1 to the denominator to make sure it doesn't reach 1 here when
// filePos == fileEnd.
return (float)(filePos - fileStart) / ... | java |
private int guessNextBGZFPos(int p, int end)
throws IOException
{
for (;;) {
for (;;) {
in.seek(p);
in.read(buf.array(), 0, 4);
int n = buf.getInt(0);
if (n == BGZF_MAGIC)
break;
// Skip ahead a bit more than 1 byte if you can.
if (n >>> 8 == BGZF_MAGIC << 8 >>> 8)
++p;
e... | java |
private static void writeTerminatorBlock(final OutputStream out, final SAMFormat samOutputFormat) throws IOException {
if (SAMFormat.CRAM == samOutputFormat) {
CramIO.issueEOF(CramVersions.DEFAULT_CRAM_VERSION, out); // terminate with CRAM EOF container
} else if (SAMFormat.BAM == samOutputFormat) {
... | java |
public static <T extends Locatable> void setIntervals(Configuration conf,
List<T> intervals) {
setTraversalParameters(conf, intervals, false);
} | java |
public static void unsetTraversalParameters(Configuration conf) {
conf.unset(BOUNDED_TRAVERSAL_PROPERTY);
conf.unset(INTERVALS_PROPERTY);
conf.unset(TRAVERSE_UNPLACED_UNMAPPED_PROPERTY);
} | java |
static QueryInterval[] prepareQueryIntervals( final List<Interval>
rawIntervals, final SAMSequenceDictionary sequenceDictionary ) {
if ( rawIntervals == null || rawIntervals.isEmpty() ) {
return null;
}
// Convert each SimpleInterval to a QueryInterval
final QueryInterval[] convertedIntervals =
rawIn... | java |
private static QueryInterval convertSimpleIntervalToQueryInterval( final Interval interval, final SAMSequenceDictionary sequenceDictionary ) {
if (interval == null) {
throw new IllegalArgumentException("interval may not be null");
}
if (sequenceDictionary == null) {
throw new IllegalArgumentException("seque... | java |
public static void convertQuality(Text quality, BaseQualityEncoding current, BaseQualityEncoding target)
{
if (current == target)
throw new IllegalArgumentException("current and target quality encodinds are the same (" + current + ")");
byte[] bytes = quality.getBytes();
final int len = quality.getLength();
... | java |
public static int verifyQuality(Text quality, BaseQualityEncoding encoding)
{
// set allowed quality range
int max, min;
if (encoding == BaseQualityEncoding.Illumina)
{
max = FormatConstants.ILLUMINA_OFFSET + FormatConstants.ILLUMINA_MAX;
min = FormatConstants.ILLUMINA_OFFSET;
}
else if (encoding ==... | java |
public static void main(String[] args) {
if (args.length == 0) {
System.out.println(
"Usage: BGZFBlockIndex [BGZF block indices...]\n\n"+
"Writes a few statistics about each BGZF block index.");
return;
}
for (String arg : args) {
final File f = new File(arg);
if (f.isFile() && f.canRead()) ... | java |
private void init(
final Path output, final SAMFileHeader header, final boolean writeHeader,
final TaskAttemptContext ctx)
throws IOException
{
init(
output.getFileSystem(ctx.getConfiguration()).create(output),
header, writeHeader, ctx);
... | java |
static List<Path> getFilesMatching(Path directory,
String syntaxAndPattern, String excludesExt) throws IOException {
PathMatcher matcher = directory.getFileSystem().getPathMatcher(syntaxAndPattern);
List<Path> parts = Files.walk(directory)
.filter(matcher::matches)
.filter(path -> excludes... | java |
static void mergeInto(List<Path> parts, OutputStream out)
throws IOException {
for (final Path part : parts) {
Files.copy(part, out);
Files.delete(part);
}
} | java |
@Override public List<InputSplit> getSplits(JobContext job)
throws IOException
{
final List<InputSplit> splits = super.getSplits(job);
// Align the splits so that they don't cross blocks
// addIndexedSplits() requires the given splits to be sorted by file
// path, so do so. Although FileInputFormat.getSpli... | java |
public static WrapSeekable<FSDataInputStream> openPath(
FileSystem fs, Path p) throws IOException
{
return new WrapSeekable<FSDataInputStream>(
fs.open(p), fs.getFileStatus(p).getLen(), p);
} | java |
public static SAMFileHeader readSAMHeaderFrom(
final InputStream in, final Configuration conf)
{
final ValidationStringency
stringency = getValidationStringency(conf);
SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
.setUseAsync... | java |
public long skip(long n) throws IOException
{
boolean end = false;
long toskip = n;
while (toskip > 0 && !end)
{
if (bufferPosn < bufferLength)
{
int skipped = (int)Math.min(bufferLength - bufferPosn, toskip);
bufferPosn += skipped;
toskip -= skipped;
}
if (bufferPosn >= bufferLength)
... | java |
@Override public float getProgress() {
if (length == 0)
return 1;
if (!isBGZF)
return (float)(in.getPosition() - fileStart) / length;
try {
if (in.peek() == -1)
return 1;
} catch (IOException e) {
return 1;
}
// Add 1 to the denominator to make sure that we never report 1 here.
return (... | java |
public void processAlignment(final SAMRecord rec) throws IOException {
// write an offset for the first record and for the g-th record thereafter (where
// g is the granularity), to be consistent with the index method
if (count == 0 || (count + 1) % granularity == 0) {
SAMFileSource fileSource = rec.getFileSou... | java |
public void writeVirtualOffset(long virtualOffset) throws IOException {
lb.put(0, virtualOffset);
out.write(byteBuffer.array());
} | java |
public static void index(
final InputStream rawIn, final OutputStream out, final long inputSize,
final int granularity)
throws IOException
{
final BlockCompressedInputStream in =
new BlockCompressedInputStream(rawIn);
final ByteBuffer byteBuffer = ByteBuffer.allocate(8); // Enough to fit a long
final... | java |
public static List<Interval> getIntervals(final Configuration conf, final String intervalPropertyName) {
final String intervalsProperty = conf.get(intervalPropertyName);
if (intervalsProperty == null) {
return null;
}
if (intervalsProperty.isEmpty()) {
return Immu... | java |
@Override public long getLength() {
final long vsHi = vStart & ~0xffff;
final long veHi = vEnd & ~0xffff;
final long hiDiff = veHi - vsHi;
return hiDiff == 0 ? ((vEnd & 0xffff) - (vStart & 0xffff)) : hiDiff;
} | java |
private void fixBCFSplits(
List<FileSplit> splits, List<InputSplit> newSplits)
throws IOException
{
// addGuessedSplits() requires the given splits to be sorted by file
// path, so do so. Although FileInputFormat.getSplits() does, at the time
// of writing this, generate them in that order, we shouldn't rel... | java |
public static boolean parseBoolean(String value, boolean defaultValue)
{
if (value == null)
return defaultValue;
value = value.trim();
// any of the following will
final String[] acceptedTrue = new String[]{ "yes", "true", "t", "y", "1" };
final String[] acceptedFalse = new String[]{ "no", "false", "f"... | java |
public static void main(String[] args) {
if (args.length == 0) {
System.out.println(
"Usage: SplittingBAMIndex [splitting BAM indices...]\n\n"+
"Writes a few statistics about each splitting BAM index.");
return;
}
for (String arg : args) {
final File f = new File(arg);
if (f.isFile() && f.ca... | java |
public static synchronized void cancelNetworkCall(String url, String requestMethod, long endTime, String exception) {
if (url != null) {
String id = sanitiseURL(url);
if ((connections != null) && (connections.containsKey(id))) {
connections.remove(id);
}
}
} | java |
private static int postRUM(String apiKey, String jsonPayload) {
try {
if (validateApiKey(apiKey)) {
String endpoint = RaygunSettings.getRUMEndpoint();
MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient.Builder()
... | java |
public static void init(Context context) {
String apiKey = readApiKey(context);
init(context, apiKey);
} | java |
public static void init(Context context, String apiKey) {
RaygunClient.apiKey = apiKey;
RaygunClient.context = context;
RaygunClient.appContextIdentifier = UUID.randomUUID().toString();
RaygunLogger.d("Configuring Raygun (v"+RaygunSettings.RAYGUN_CLIENT_VERSION+")");
try {
RaygunClient.versi... | java |
public static void init(Context context, String apiKey, String version) {
init(context, apiKey);
RaygunClient.version = version;
} | java |
public static void send(Throwable throwable, List tags, Map userCustomData) {
RaygunMessage msg = buildMessage(throwable);
if (msg == null) {
RaygunLogger.e("Failed to send RaygunMessage - due to invalid message being built");
return;
}
msg.getDetails().setTags(RaygunUtils.mergeLists(Raygu... | java |
public static void sendPulseTimingEvent(RaygunPulseEventType eventType, String name, long milliseconds) {
if (RaygunClient.sessionId == null) {
sendPulseEvent(RaygunSettings.RUM_EVENT_SESSION_START);
}
if (eventType == RaygunPulseEventType.ACTIVITY_LOADED) {
if (RaygunClient.shouldIgnoreView(na... | java |
public static <T extends Tag, V> void register(Class<T> tag, Class<V> type, TagConverter<T, V> converter) throws ConverterRegisterException {
if(tagToConverter.containsKey(tag)) {
throw new ConverterRegisterException("Type conversion to tag " + tag.getName() + " is already registered.");
}
... | java |
public static <T extends Tag, V> void unregister(Class<T> tag, Class<V> type) {
tagToConverter.remove(tag);
typeToConverter.remove(type);
} | java |
public static <T extends Tag, V> V convertToValue(T tag) throws ConversionException {
if(tag == null || tag.getValue() == null) {
return null;
}
if(!tagToConverter.containsKey(tag.getClass())) {
throw new ConversionException("Tag type " + tag.getClass().getName() + " has... | java |
public static <V, T extends Tag> T convertToTag(String name, V value) throws ConversionException {
if(value == null) {
return null;
}
TagConverter<T, V> converter = (TagConverter<T, V>) typeToConverter.get(value.getClass());
if(converter == null) {
for(Class<?> c... | java |
public static void writeTag(OutputStream out, Tag tag) throws IOException {
writeTag(out, tag, false);
} | java |
public void setValue(List<Tag> value) throws IllegalArgumentException {
this.type = null;
this.value.clear();
for(Tag tag : value) {
this.add(tag);
}
} | java |
public boolean add(Tag tag) throws IllegalArgumentException {
if(tag == null) {
return false;
}
// If empty list, use this as tag type.
if(this.type == null) {
this.type = tag.getClass();
} else if(tag.getClass() != this.type) {
throw new Ille... | java |
public void setValue(Map<String, Tag> value) {
this.value = new LinkedHashMap<String, Tag>(value);
} | java |
public <T extends Tag> T get(String tagName) {
return (T) this.value.get(tagName);
} | java |
public <T extends Tag> T put(T tag) {
return (T) this.value.put(tag.getName(), tag);
} | java |
public <T extends Tag> T remove(String tagName) {
return (T) this.value.remove(tagName);
} | java |
public static void register(int id, Class<? extends Tag> tag) throws TagRegisterException {
if(idToTag.containsKey(id)) {
throw new TagRegisterException("Tag ID \"" + id + "\" is already in use.");
}
if(tagToId.containsKey(tag)) {
throw new TagRegisterException("Tag \"" ... | java |
public static Class<? extends Tag> getClassFor(int id) {
if(!idToTag.containsKey(id)) {
return null;
}
return idToTag.get(id);
} | java |
public static int getIdFor(Class<? extends Tag> clazz) {
if(!tagToId.containsKey(clazz)) {
return -1;
}
return tagToId.get(clazz);
} | java |
public static Tag createInstance(int id, String tagName) throws TagCreateException {
Class<? extends Tag> clazz = idToTag.get(id);
if(clazz == null) {
throw new TagCreateException("Could not find tag with ID \"" + id + "\".");
}
try {
Constructor<? extends Tag> c... | java |
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = 200;
if (MeasureSpec.UNSPECIFIED != MeasureSpec.getMode(widthMeasureSpec)) {
width = MeasureSpec.getSize(widthMeasureSpec);
}
int height = thumbImage.getHeight()
... | java |
private void drawThumb(float screenCoord, boolean pressed, Canvas canvas, boolean areSelectedValuesDefault) {
Bitmap buttonToDraw;
if (!activateOnDefaultValues && areSelectedValuesDefault) {
buttonToDraw = thumbDisabledImage;
} else {
buttonToDraw = pressed ? thumbPressed... | java |
private void drawThumbShadow(float screenCoord, Canvas canvas) {
thumbShadowMatrix.setTranslate(screenCoord + thumbShadowXOffset, textOffset + thumbHalfHeight + thumbShadowYOffset);
translatedThumbShadowPath.set(thumbShadowPath);
translatedThumbShadowPath.transform(thumbShadowMatrix);
ca... | java |
private void setNormalizedMinValue(double value) {
normalizedMinValue = Math.max(0d, Math.min(1d, Math.min(value, normalizedMaxValue)));
invalidate();
} | java |
private void setNormalizedMaxValue(double value) {
normalizedMaxValue = Math.max(0d, Math.min(1d, Math.max(value, normalizedMinValue)));
invalidate();
} | java |
@SuppressWarnings("unchecked")
protected T normalizedToValue(double normalized) {
double v = absoluteMinValuePrim + normalized * (absoluteMaxValuePrim - absoluteMinValuePrim);
// TODO parameterize this rounding to allow variable decimal points
return (T) numberType.toNumber(Math.round(v * 10... | java |
protected double valueToNormalized(T value) {
if (0 == absoluteMaxValuePrim - absoluteMinValuePrim) {
// prevent division by zero, simply return 0.
return 0d;
}
return (value.doubleValue() - absoluteMinValuePrim) / (absoluteMaxValuePrim - absoluteMinValuePrim);
} | java |
private double screenToNormalized(float screenCoord) {
int width = getWidth();
if (width <= 2 * padding) {
// prevent division by zero, simply return 0.
return 0d;
} else {
double result = (screenCoord - padding) / (width - 2 * padding);
return Mat... | java |
public static <K> void updateWeights(double l2, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
if(l2 > 0.0) {
for(Map.Entry<K, Double> e : weights.entrySet()) {
K column = e.getKey();
newWeights.put(column, newWeights.get(column) + l2*e.getV... | java |
public static <K> double estimatePenalty(double l2, Map<K, Double> weights) {
double penalty = 0.0;
if(l2 > 0.0) {
double sumWeightsSquared = 0.0;
for(double w : weights.values()) {
sumWeightsSquared += w*w;
}
penalty = l2*sumWeightsSquared... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.