repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/util/UIUtils.java | UIUtils.getScreenWidth | public static int getScreenWidth(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return metrics.widthPixels;
} | java | public static int getScreenWidth(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return metrics.widthPixels;
} | [
"public",
"static",
"int",
"getScreenWidth",
"(",
"Context",
"context",
")",
"{",
"DisplayMetrics",
"metrics",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
";",
"return",
"metrics",
".",
"widthPixels",
";",
"}"
] | Returns the screen width in pixels
@param context is the context to get the resources
@return the screen width in pixels | [
"Returns",
"the",
"screen",
"width",
"in",
"pixels"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L334-L337 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/util/UIUtils.java | UIUtils.getScreenHeight | public static int getScreenHeight(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return metrics.heightPixels;
} | java | public static int getScreenHeight(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return metrics.heightPixels;
} | [
"public",
"static",
"int",
"getScreenHeight",
"(",
"Context",
"context",
")",
"{",
"DisplayMetrics",
"metrics",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
";",
"return",
"metrics",
".",
"heightPixels",
";",
"}"
] | Returns the screen height in pixels
@param context is the context to get the resources
@return the screen height in pixels | [
"Returns",
"the",
"screen",
"height",
"in",
"pixels"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L346-L349 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java | MaterializeBuilder.withActivity | public MaterializeBuilder withActivity(Activity activity) {
this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content);
this.mActivity = activity;
return this;
} | java | public MaterializeBuilder withActivity(Activity activity) {
this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content);
this.mActivity = activity;
return this;
} | [
"public",
"MaterializeBuilder",
"withActivity",
"(",
"Activity",
"activity",
")",
"{",
"this",
".",
"mRootView",
"=",
"(",
"ViewGroup",
")",
"activity",
".",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"content",
")",
";",
"this",
".",
"mActi... | Pass the activity you use the drawer in ;)
This is required if you want to set any values by resource
@param activity
@return | [
"Pass",
"the",
"activity",
"you",
"use",
"the",
"drawer",
"in",
";",
")",
"This",
"is",
"required",
"if",
"you",
"want",
"to",
"set",
"any",
"values",
"by",
"resource"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java#L53-L57 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java | MaterializeBuilder.withContainer | public MaterializeBuilder withContainer(ViewGroup container, ViewGroup.LayoutParams layoutParams) {
this.mContainer = container;
this.mContainerLayoutParams = layoutParams;
return this;
} | java | public MaterializeBuilder withContainer(ViewGroup container, ViewGroup.LayoutParams layoutParams) {
this.mContainer = container;
this.mContainerLayoutParams = layoutParams;
return this;
} | [
"public",
"MaterializeBuilder",
"withContainer",
"(",
"ViewGroup",
"container",
",",
"ViewGroup",
".",
"LayoutParams",
"layoutParams",
")",
"{",
"this",
".",
"mContainer",
"=",
"container",
";",
"this",
".",
"mContainerLayoutParams",
"=",
"layoutParams",
";",
"retur... | set the layout which will host the ScrimInsetsFrameLayout and its layoutParams
@param container
@param layoutParams
@return | [
"set",
"the",
"layout",
"which",
"will",
"host",
"the",
"ScrimInsetsFrameLayout",
"and",
"its",
"layoutParams"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java#L314-L318 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/Materialize.java | Materialize.setFullscreen | public void setFullscreen(boolean fullscreen) {
if (mBuilder.mScrimInsetsLayout != null) {
mBuilder.mScrimInsetsLayout.setTintStatusBar(!fullscreen);
mBuilder.mScrimInsetsLayout.setTintNavigationBar(!fullscreen);
}
} | java | public void setFullscreen(boolean fullscreen) {
if (mBuilder.mScrimInsetsLayout != null) {
mBuilder.mScrimInsetsLayout.setTintStatusBar(!fullscreen);
mBuilder.mScrimInsetsLayout.setTintNavigationBar(!fullscreen);
}
} | [
"public",
"void",
"setFullscreen",
"(",
"boolean",
"fullscreen",
")",
"{",
"if",
"(",
"mBuilder",
".",
"mScrimInsetsLayout",
"!=",
"null",
")",
"{",
"mBuilder",
".",
"mScrimInsetsLayout",
".",
"setTintStatusBar",
"(",
"!",
"fullscreen",
")",
";",
"mBuilder",
"... | set the insetsFrameLayout to display the content in fullscreen
under the statusBar and navigationBar
@param fullscreen | [
"set",
"the",
"insetsFrameLayout",
"to",
"display",
"the",
"content",
"in",
"fullscreen",
"under",
"the",
"statusBar",
"and",
"navigationBar"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L31-L36 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/Materialize.java | Materialize.setStatusBarColor | public void setStatusBarColor(int statusBarColor) {
if (mBuilder.mScrimInsetsLayout != null) {
mBuilder.mScrimInsetsLayout.setInsetForeground(statusBarColor);
mBuilder.mScrimInsetsLayout.getView().invalidate();
}
} | java | public void setStatusBarColor(int statusBarColor) {
if (mBuilder.mScrimInsetsLayout != null) {
mBuilder.mScrimInsetsLayout.setInsetForeground(statusBarColor);
mBuilder.mScrimInsetsLayout.getView().invalidate();
}
} | [
"public",
"void",
"setStatusBarColor",
"(",
"int",
"statusBarColor",
")",
"{",
"if",
"(",
"mBuilder",
".",
"mScrimInsetsLayout",
"!=",
"null",
")",
"{",
"mBuilder",
".",
"mScrimInsetsLayout",
".",
"setInsetForeground",
"(",
"statusBarColor",
")",
";",
"mBuilder",
... | Set the color for the statusBar
@param statusBarColor | [
"Set",
"the",
"color",
"for",
"the",
"statusBar"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L65-L70 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/Materialize.java | Materialize.keyboardSupportEnabled | public void keyboardSupportEnabled(Activity activity, boolean enable) {
if (getContent() != null && getContent().getChildCount() > 0) {
if (mKeyboardUtil == null) {
mKeyboardUtil = new KeyboardUtil(activity, getContent().getChildAt(0));
mKeyboardUtil.disable();
}
if (enable) {
mKeyboardUtil.enable();
} else {
mKeyboardUtil.disable();
}
}
} | java | public void keyboardSupportEnabled(Activity activity, boolean enable) {
if (getContent() != null && getContent().getChildCount() > 0) {
if (mKeyboardUtil == null) {
mKeyboardUtil = new KeyboardUtil(activity, getContent().getChildAt(0));
mKeyboardUtil.disable();
}
if (enable) {
mKeyboardUtil.enable();
} else {
mKeyboardUtil.disable();
}
}
} | [
"public",
"void",
"keyboardSupportEnabled",
"(",
"Activity",
"activity",
",",
"boolean",
"enable",
")",
"{",
"if",
"(",
"getContent",
"(",
")",
"!=",
"null",
"&&",
"getContent",
"(",
")",
".",
"getChildCount",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"... | a helper method to enable the keyboardUtil for a specific activity
or disable it. note this will cause some frame drops because of the
listener.
@param activity
@param enable | [
"a",
"helper",
"method",
"to",
"enable",
"the",
"keyboardUtil",
"for",
"a",
"specific",
"activity",
"or",
"disable",
"it",
".",
"note",
"this",
"will",
"cause",
"some",
"frame",
"drops",
"because",
"of",
"the",
"listener",
"."
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L99-L112 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyTo | public void applyTo(Context ctx, GradientDrawable drawable) {
if (mColorInt != 0) {
drawable.setColor(mColorInt);
} else if (mColorRes != -1) {
drawable.setColor(ContextCompat.getColor(ctx, mColorRes));
}
} | java | public void applyTo(Context ctx, GradientDrawable drawable) {
if (mColorInt != 0) {
drawable.setColor(mColorInt);
} else if (mColorRes != -1) {
drawable.setColor(ContextCompat.getColor(ctx, mColorRes));
}
} | [
"public",
"void",
"applyTo",
"(",
"Context",
"ctx",
",",
"GradientDrawable",
"drawable",
")",
"{",
"if",
"(",
"mColorInt",
"!=",
"0",
")",
"{",
"drawable",
".",
"setColor",
"(",
"mColorInt",
")",
";",
"}",
"else",
"if",
"(",
"mColorRes",
"!=",
"-",
"1"... | set the textColor of the ColorHolder to an drawable
@param ctx
@param drawable | [
"set",
"the",
"textColor",
"of",
"the",
"ColorHolder",
"to",
"an",
"drawable"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L61-L67 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyToBackground | public void applyToBackground(View view) {
if (mColorInt != 0) {
view.setBackgroundColor(mColorInt);
} else if (mColorRes != -1) {
view.setBackgroundResource(mColorRes);
}
} | java | public void applyToBackground(View view) {
if (mColorInt != 0) {
view.setBackgroundColor(mColorInt);
} else if (mColorRes != -1) {
view.setBackgroundResource(mColorRes);
}
} | [
"public",
"void",
"applyToBackground",
"(",
"View",
"view",
")",
"{",
"if",
"(",
"mColorInt",
"!=",
"0",
")",
"{",
"view",
".",
"setBackgroundColor",
"(",
"mColorInt",
")",
";",
"}",
"else",
"if",
"(",
"mColorRes",
"!=",
"-",
"1",
")",
"{",
"view",
"... | set the textColor of the ColorHolder to a view
@param view | [
"set",
"the",
"textColor",
"of",
"the",
"ColorHolder",
"to",
"a",
"view"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L75-L81 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyToOr | public void applyToOr(TextView textView, ColorStateList colorDefault) {
if (mColorInt != 0) {
textView.setTextColor(mColorInt);
} else if (mColorRes != -1) {
textView.setTextColor(ContextCompat.getColor(textView.getContext(), mColorRes));
} else if (colorDefault != null) {
textView.setTextColor(colorDefault);
}
} | java | public void applyToOr(TextView textView, ColorStateList colorDefault) {
if (mColorInt != 0) {
textView.setTextColor(mColorInt);
} else if (mColorRes != -1) {
textView.setTextColor(ContextCompat.getColor(textView.getContext(), mColorRes));
} else if (colorDefault != null) {
textView.setTextColor(colorDefault);
}
} | [
"public",
"void",
"applyToOr",
"(",
"TextView",
"textView",
",",
"ColorStateList",
"colorDefault",
")",
"{",
"if",
"(",
"mColorInt",
"!=",
"0",
")",
"{",
"textView",
".",
"setTextColor",
"(",
"mColorInt",
")",
";",
"}",
"else",
"if",
"(",
"mColorRes",
"!="... | a small helper to set the text color to a textView null save
@param textView
@param colorDefault | [
"a",
"small",
"helper",
"to",
"set",
"the",
"text",
"color",
"to",
"a",
"textView",
"null",
"save"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L89-L97 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.color | public int color(Context ctx) {
if (mColorInt == 0 && mColorRes != -1) {
mColorInt = ContextCompat.getColor(ctx, mColorRes);
}
return mColorInt;
} | java | public int color(Context ctx) {
if (mColorInt == 0 && mColorRes != -1) {
mColorInt = ContextCompat.getColor(ctx, mColorRes);
}
return mColorInt;
} | [
"public",
"int",
"color",
"(",
"Context",
"ctx",
")",
"{",
"if",
"(",
"mColorInt",
"==",
"0",
"&&",
"mColorRes",
"!=",
"-",
"1",
")",
"{",
"mColorInt",
"=",
"ContextCompat",
".",
"getColor",
"(",
"ctx",
",",
"mColorRes",
")",
";",
"}",
"return",
"mCo... | a small helper to get the color from the colorHolder
@param ctx
@return | [
"a",
"small",
"helper",
"to",
"get",
"the",
"color",
"from",
"the",
"colorHolder"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L123-L128 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.color | public static int color(ColorHolder colorHolder, Context ctx) {
if (colorHolder == null) {
return 0;
} else {
return colorHolder.color(ctx);
}
} | java | public static int color(ColorHolder colorHolder, Context ctx) {
if (colorHolder == null) {
return 0;
} else {
return colorHolder.color(ctx);
}
} | [
"public",
"static",
"int",
"color",
"(",
"ColorHolder",
"colorHolder",
",",
"Context",
"ctx",
")",
"{",
"if",
"(",
"colorHolder",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"colorHolder",
".",
"color",
"(",
"ctx",
")",
";",... | a small static helper class to get the color from the colorHolder
@param colorHolder
@param ctx
@return | [
"a",
"small",
"static",
"helper",
"class",
"to",
"get",
"the",
"color",
"from",
"the",
"colorHolder"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L154-L160 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyToOr | public static void applyToOr(ColorHolder colorHolder, TextView textView, ColorStateList colorDefault) {
if (colorHolder != null && textView != null) {
colorHolder.applyToOr(textView, colorDefault);
} else if (textView != null) {
textView.setTextColor(colorDefault);
}
} | java | public static void applyToOr(ColorHolder colorHolder, TextView textView, ColorStateList colorDefault) {
if (colorHolder != null && textView != null) {
colorHolder.applyToOr(textView, colorDefault);
} else if (textView != null) {
textView.setTextColor(colorDefault);
}
} | [
"public",
"static",
"void",
"applyToOr",
"(",
"ColorHolder",
"colorHolder",
",",
"TextView",
"textView",
",",
"ColorStateList",
"colorDefault",
")",
"{",
"if",
"(",
"colorHolder",
"!=",
"null",
"&&",
"textView",
"!=",
"null",
")",
"{",
"colorHolder",
".",
"app... | a small static helper to set the text color to a textView null save
@param colorHolder
@param textView
@param colorDefault | [
"a",
"small",
"static",
"helper",
"to",
"set",
"the",
"text",
"color",
"to",
"a",
"textView",
"null",
"save"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L169-L175 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java | ColorHolder.applyToOrTransparent | public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
if (colorHolder != null && gradientDrawable != null) {
colorHolder.applyTo(ctx, gradientDrawable);
} else if (gradientDrawable != null) {
gradientDrawable.setColor(Color.TRANSPARENT);
}
} | java | public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
if (colorHolder != null && gradientDrawable != null) {
colorHolder.applyTo(ctx, gradientDrawable);
} else if (gradientDrawable != null) {
gradientDrawable.setColor(Color.TRANSPARENT);
}
} | [
"public",
"static",
"void",
"applyToOrTransparent",
"(",
"ColorHolder",
"colorHolder",
",",
"Context",
"ctx",
",",
"GradientDrawable",
"gradientDrawable",
")",
"{",
"if",
"(",
"colorHolder",
"!=",
"null",
"&&",
"gradientDrawable",
"!=",
"null",
")",
"{",
"colorHol... | a small static helper to set the color to a GradientDrawable null save
@param colorHolder
@param ctx
@param gradientDrawable | [
"a",
"small",
"static",
"helper",
"to",
"set",
"the",
"color",
"to",
"a",
"GradientDrawable",
"null",
"save"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L184-L190 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java | ImageHolder.applyTo | public static boolean applyTo(ImageHolder imageHolder, ImageView imageView, String tag) {
if (imageHolder != null && imageView != null) {
return imageHolder.applyTo(imageView, tag);
}
return false;
} | java | public static boolean applyTo(ImageHolder imageHolder, ImageView imageView, String tag) {
if (imageHolder != null && imageView != null) {
return imageHolder.applyTo(imageView, tag);
}
return false;
} | [
"public",
"static",
"boolean",
"applyTo",
"(",
"ImageHolder",
"imageHolder",
",",
"ImageView",
"imageView",
",",
"String",
"tag",
")",
"{",
"if",
"(",
"imageHolder",
"!=",
"null",
"&&",
"imageView",
"!=",
"null",
")",
"{",
"return",
"imageHolder",
".",
"appl... | a small static helper to set the image from the imageHolder nullSave to the imageView
@param imageHolder
@param imageView
@param tag used to identify imageViews and define different placeholders
@return true if an image was set | [
"a",
"small",
"static",
"helper",
"to",
"set",
"the",
"image",
"from",
"the",
"imageHolder",
"nullSave",
"to",
"the",
"imageView"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L170-L175 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java | ImageHolder.decideIcon | public static Drawable decideIcon(ImageHolder imageHolder, Context ctx, int iconColor, boolean tint) {
if (imageHolder == null) {
return null;
} else {
return imageHolder.decideIcon(ctx, iconColor, tint);
}
} | java | public static Drawable decideIcon(ImageHolder imageHolder, Context ctx, int iconColor, boolean tint) {
if (imageHolder == null) {
return null;
} else {
return imageHolder.decideIcon(ctx, iconColor, tint);
}
} | [
"public",
"static",
"Drawable",
"decideIcon",
"(",
"ImageHolder",
"imageHolder",
",",
"Context",
"ctx",
",",
"int",
"iconColor",
",",
"boolean",
"tint",
")",
"{",
"if",
"(",
"imageHolder",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
... | a small static helper which catches nulls for us
@param imageHolder
@param ctx
@param iconColor
@param tint
@return | [
"a",
"small",
"static",
"helper",
"which",
"catches",
"nulls",
"for",
"us"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L243-L249 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java | ImageHolder.applyDecidedIconOrSetGone | public static void applyDecidedIconOrSetGone(ImageHolder imageHolder, ImageView imageView, int iconColor, boolean tint) {
if (imageHolder != null && imageView != null) {
Drawable drawable = ImageHolder.decideIcon(imageHolder, imageView.getContext(), iconColor, tint);
if (drawable != null) {
imageView.setImageDrawable(drawable);
imageView.setVisibility(View.VISIBLE);
} else if (imageHolder.getBitmap() != null) {
imageView.setImageBitmap(imageHolder.getBitmap());
imageView.setVisibility(View.VISIBLE);
} else {
imageView.setVisibility(View.GONE);
}
} else if (imageView != null) {
imageView.setVisibility(View.GONE);
}
} | java | public static void applyDecidedIconOrSetGone(ImageHolder imageHolder, ImageView imageView, int iconColor, boolean tint) {
if (imageHolder != null && imageView != null) {
Drawable drawable = ImageHolder.decideIcon(imageHolder, imageView.getContext(), iconColor, tint);
if (drawable != null) {
imageView.setImageDrawable(drawable);
imageView.setVisibility(View.VISIBLE);
} else if (imageHolder.getBitmap() != null) {
imageView.setImageBitmap(imageHolder.getBitmap());
imageView.setVisibility(View.VISIBLE);
} else {
imageView.setVisibility(View.GONE);
}
} else if (imageView != null) {
imageView.setVisibility(View.GONE);
}
} | [
"public",
"static",
"void",
"applyDecidedIconOrSetGone",
"(",
"ImageHolder",
"imageHolder",
",",
"ImageView",
"imageView",
",",
"int",
"iconColor",
",",
"boolean",
"tint",
")",
"{",
"if",
"(",
"imageHolder",
"!=",
"null",
"&&",
"imageView",
"!=",
"null",
")",
... | decides which icon to apply or hide this view
@param imageHolder
@param imageView
@param iconColor
@param tint | [
"decides",
"which",
"icon",
"to",
"apply",
"or",
"hide",
"this",
"view"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L259-L274 | train |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java | ImageHolder.applyMultiIconTo | public static void applyMultiIconTo(Drawable icon, int iconColor, Drawable selectedIcon, int selectedIconColor, boolean tinted, ImageView imageView) {
//if we have an icon then we want to set it
if (icon != null) {
//if we got a different color for the selectedIcon we need a StateList
if (selectedIcon != null) {
if (tinted) {
imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, selectedIcon, iconColor, selectedIconColor));
} else {
imageView.setImageDrawable(UIUtils.getIconStateList(icon, selectedIcon));
}
} else if (tinted) {
imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, iconColor, selectedIconColor));
} else {
imageView.setImageDrawable(icon);
}
//make sure we display the icon
imageView.setVisibility(View.VISIBLE);
} else {
//hide the icon
imageView.setVisibility(View.GONE);
}
} | java | public static void applyMultiIconTo(Drawable icon, int iconColor, Drawable selectedIcon, int selectedIconColor, boolean tinted, ImageView imageView) {
//if we have an icon then we want to set it
if (icon != null) {
//if we got a different color for the selectedIcon we need a StateList
if (selectedIcon != null) {
if (tinted) {
imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, selectedIcon, iconColor, selectedIconColor));
} else {
imageView.setImageDrawable(UIUtils.getIconStateList(icon, selectedIcon));
}
} else if (tinted) {
imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, iconColor, selectedIconColor));
} else {
imageView.setImageDrawable(icon);
}
//make sure we display the icon
imageView.setVisibility(View.VISIBLE);
} else {
//hide the icon
imageView.setVisibility(View.GONE);
}
} | [
"public",
"static",
"void",
"applyMultiIconTo",
"(",
"Drawable",
"icon",
",",
"int",
"iconColor",
",",
"Drawable",
"selectedIcon",
",",
"int",
"selectedIconColor",
",",
"boolean",
"tinted",
",",
"ImageView",
"imageView",
")",
"{",
"//if we have an icon then we want to... | a small static helper to set a multi state drawable on a view
@param icon
@param iconColor
@param selectedIcon
@param selectedIconColor
@param tinted
@param imageView | [
"a",
"small",
"static",
"helper",
"to",
"set",
"a",
"multi",
"state",
"drawable",
"on",
"a",
"view"
] | 2612c10c7570191a78d57f23620e945d61370e3d | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L286-L307 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.setHighlightStrength | public void setHighlightStrength(float _highlightStrength) {
mHighlightStrength = _highlightStrength;
for (PieModel model : mPieData) {
highlightSlice(model);
}
invalidateGlobal();
} | java | public void setHighlightStrength(float _highlightStrength) {
mHighlightStrength = _highlightStrength;
for (PieModel model : mPieData) {
highlightSlice(model);
}
invalidateGlobal();
} | [
"public",
"void",
"setHighlightStrength",
"(",
"float",
"_highlightStrength",
")",
"{",
"mHighlightStrength",
"=",
"_highlightStrength",
";",
"for",
"(",
"PieModel",
"model",
":",
"mPieData",
")",
"{",
"highlightSlice",
"(",
"model",
")",
";",
"}",
"invalidateGlob... | Sets the highlight strength for the InnerPaddingOutline.
@param _highlightStrength The highlighting value for the outline. | [
"Sets",
"the",
"highlight",
"strength",
"for",
"the",
"InnerPaddingOutline",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L256-L262 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.addPieSlice | public void addPieSlice(PieModel _Slice) {
highlightSlice(_Slice);
mPieData.add(_Slice);
mTotalValue += _Slice.getValue();
onDataChanged();
} | java | public void addPieSlice(PieModel _Slice) {
highlightSlice(_Slice);
mPieData.add(_Slice);
mTotalValue += _Slice.getValue();
onDataChanged();
} | [
"public",
"void",
"addPieSlice",
"(",
"PieModel",
"_Slice",
")",
"{",
"highlightSlice",
"(",
"_Slice",
")",
";",
"mPieData",
".",
"add",
"(",
"_Slice",
")",
";",
"mTotalValue",
"+=",
"_Slice",
".",
"getValue",
"(",
")",
";",
"onDataChanged",
"(",
")",
";... | Adds a new Pie Slice to the PieChart. After inserting and calculation of the highlighting color
a complete recalculation is initiated.
@param _Slice The newly added PieSlice. | [
"Adds",
"a",
"new",
"Pie",
"Slice",
"to",
"the",
"PieChart",
".",
"After",
"inserting",
"and",
"calculation",
"of",
"the",
"highlighting",
"color",
"a",
"complete",
"recalculation",
"is",
"initiated",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L499-L504 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.onDraw | @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// If the API level is less than 11, we can't rely on the view animation system to
// do the scrolling animation. Need to tick it here and call postInvalidate() until the scrolling is done.
if (Build.VERSION.SDK_INT < 11) {
tickScrollAnimation();
if (!mScroller.isFinished()) {
mGraph.postInvalidate();
}
}
} | java | @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// If the API level is less than 11, we can't rely on the view animation system to
// do the scrolling animation. Need to tick it here and call postInvalidate() until the scrolling is done.
if (Build.VERSION.SDK_INT < 11) {
tickScrollAnimation();
if (!mScroller.isFinished()) {
mGraph.postInvalidate();
}
}
} | [
"@",
"Override",
"protected",
"void",
"onDraw",
"(",
"Canvas",
"canvas",
")",
"{",
"super",
".",
"onDraw",
"(",
"canvas",
")",
";",
"// If the API level is less than 11, we can't rely on the view animation system to",
"// do the scrolling animation. Need to tick it here and call ... | Implement this to do your drawing.
@param canvas the canvas on which the background will be drawn | [
"Implement",
"this",
"to",
"do",
"your",
"drawing",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L559-L571 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.onDataChanged | @Override
protected void onDataChanged() {
super.onDataChanged();
int currentAngle = 0;
int index = 0;
int size = mPieData.size();
for (PieModel model : mPieData) {
int endAngle = (int) (currentAngle + model.getValue() * 360.f / mTotalValue);
if(index == size-1) {
endAngle = 360;
}
model.setStartAngle(currentAngle);
model.setEndAngle(endAngle);
currentAngle = model.getEndAngle();
index++;
}
calcCurrentItem();
onScrollFinished();
} | java | @Override
protected void onDataChanged() {
super.onDataChanged();
int currentAngle = 0;
int index = 0;
int size = mPieData.size();
for (PieModel model : mPieData) {
int endAngle = (int) (currentAngle + model.getValue() * 360.f / mTotalValue);
if(index == size-1) {
endAngle = 360;
}
model.setStartAngle(currentAngle);
model.setEndAngle(endAngle);
currentAngle = model.getEndAngle();
index++;
}
calcCurrentItem();
onScrollFinished();
} | [
"@",
"Override",
"protected",
"void",
"onDataChanged",
"(",
")",
"{",
"super",
".",
"onDataChanged",
"(",
")",
";",
"int",
"currentAngle",
"=",
"0",
";",
"int",
"index",
"=",
"0",
";",
"int",
"size",
"=",
"mPieData",
".",
"size",
"(",
")",
";",
"for"... | Should be called after new data is inserted. Will be automatically called, when the view dimensions
has changed.
Calculates the start- and end-angles for every PieSlice. | [
"Should",
"be",
"called",
"after",
"new",
"data",
"is",
"inserted",
".",
"Will",
"be",
"automatically",
"called",
"when",
"the",
"view",
"dimensions",
"has",
"changed",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L717-L738 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.highlightSlice | private void highlightSlice(PieModel _Slice) {
int color = _Slice.getColor();
_Slice.setHighlightedColor(Color.argb(
0xff,
Math.min((int) (mHighlightStrength * (float) Color.red(color)), 0xff),
Math.min((int) (mHighlightStrength * (float) Color.green(color)), 0xff),
Math.min((int) (mHighlightStrength * (float) Color.blue(color)), 0xff)
));
} | java | private void highlightSlice(PieModel _Slice) {
int color = _Slice.getColor();
_Slice.setHighlightedColor(Color.argb(
0xff,
Math.min((int) (mHighlightStrength * (float) Color.red(color)), 0xff),
Math.min((int) (mHighlightStrength * (float) Color.green(color)), 0xff),
Math.min((int) (mHighlightStrength * (float) Color.blue(color)), 0xff)
));
} | [
"private",
"void",
"highlightSlice",
"(",
"PieModel",
"_Slice",
")",
"{",
"int",
"color",
"=",
"_Slice",
".",
"getColor",
"(",
")",
";",
"_Slice",
".",
"setHighlightedColor",
"(",
"Color",
".",
"argb",
"(",
"0xff",
",",
"Math",
".",
"min",
"(",
"(",
"i... | Calculate the highlight color. Saturate at 0xff to make sure that high values
don't result in aliasing.
@param _Slice The Slice which will be highlighted. | [
"Calculate",
"the",
"highlight",
"color",
".",
"Saturate",
"at",
"0xff",
"to",
"make",
"sure",
"that",
"high",
"values",
"don",
"t",
"result",
"in",
"aliasing",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L746-L755 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.calcCurrentItem | private void calcCurrentItem() {
int pointerAngle;
// calculate the correct pointer angle, depending on clockwise drawing or not
if(mOpenClockwise) {
pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360;
}
else {
pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360;
}
for (int i = 0; i < mPieData.size(); ++i) {
PieModel model = mPieData.get(i);
if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) {
if (i != mCurrentItem) {
setCurrentItem(i, false);
}
break;
}
}
} | java | private void calcCurrentItem() {
int pointerAngle;
// calculate the correct pointer angle, depending on clockwise drawing or not
if(mOpenClockwise) {
pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360;
}
else {
pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360;
}
for (int i = 0; i < mPieData.size(); ++i) {
PieModel model = mPieData.get(i);
if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) {
if (i != mCurrentItem) {
setCurrentItem(i, false);
}
break;
}
}
} | [
"private",
"void",
"calcCurrentItem",
"(",
")",
"{",
"int",
"pointerAngle",
";",
"// calculate the correct pointer angle, depending on clockwise drawing or not",
"if",
"(",
"mOpenClockwise",
")",
"{",
"pointerAngle",
"=",
"(",
"mIndicatorAngle",
"+",
"360",
"-",
"mPieRota... | Calculate which pie slice is under the pointer, and set the current item
field accordingly. | [
"Calculate",
"which",
"pie",
"slice",
"is",
"under",
"the",
"pointer",
"and",
"set",
"the",
"current",
"item",
"field",
"accordingly",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L761-L781 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java | PieChart.centerOnCurrentItem | private void centerOnCurrentItem() {
if(!mPieData.isEmpty()) {
PieModel current = mPieData.get(getCurrentItem());
int targetAngle;
if(mOpenClockwise) {
targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2);
if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360;
}
else {
targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2;
targetAngle += mIndicatorAngle;
if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360;
}
mAutoCenterAnimator.setIntValues(targetAngle);
mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start();
}
} | java | private void centerOnCurrentItem() {
if(!mPieData.isEmpty()) {
PieModel current = mPieData.get(getCurrentItem());
int targetAngle;
if(mOpenClockwise) {
targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2);
if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360;
}
else {
targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2;
targetAngle += mIndicatorAngle;
if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360;
}
mAutoCenterAnimator.setIntValues(targetAngle);
mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start();
}
} | [
"private",
"void",
"centerOnCurrentItem",
"(",
")",
"{",
"if",
"(",
"!",
"mPieData",
".",
"isEmpty",
"(",
")",
")",
"{",
"PieModel",
"current",
"=",
"mPieData",
".",
"get",
"(",
"getCurrentItem",
"(",
")",
")",
";",
"int",
"targetAngle",
";",
"if",
"("... | Kicks off an animation that will result in the pointer being centered in the
pie slice of the currently selected item. | [
"Kicks",
"off",
"an",
"animation",
"that",
"will",
"result",
"in",
"the",
"pointer",
"being",
"centered",
"in",
"the",
"pie",
"slice",
"of",
"the",
"currently",
"selected",
"item",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L819-L838 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java | ValueLineChart.onLegendDataChanged | protected void onLegendDataChanged() {
int legendCount = mLegendList.size();
float margin = (mGraphWidth / legendCount);
float currentOffset = 0;
for (LegendModel model : mLegendList) {
model.setLegendBounds(new RectF(currentOffset, 0, currentOffset + margin, mLegendHeight));
currentOffset += margin;
}
Utils.calculateLegendInformation(mLegendList, 0, mGraphWidth, mLegendPaint);
invalidateGlobal();
} | java | protected void onLegendDataChanged() {
int legendCount = mLegendList.size();
float margin = (mGraphWidth / legendCount);
float currentOffset = 0;
for (LegendModel model : mLegendList) {
model.setLegendBounds(new RectF(currentOffset, 0, currentOffset + margin, mLegendHeight));
currentOffset += margin;
}
Utils.calculateLegendInformation(mLegendList, 0, mGraphWidth, mLegendPaint);
invalidateGlobal();
} | [
"protected",
"void",
"onLegendDataChanged",
"(",
")",
"{",
"int",
"legendCount",
"=",
"mLegendList",
".",
"size",
"(",
")",
";",
"float",
"margin",
"=",
"(",
"mGraphWidth",
"/",
"legendCount",
")",
";",
"float",
"currentOffset",
"=",
"0",
";",
"for",
"(",
... | Calculates the legend bounds for a custom list of legends. | [
"Calculates",
"the",
"legend",
"bounds",
"for",
"a",
"custom",
"list",
"of",
"legends",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java#L958-L972 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java | ValueLineChart.calculateValueTextHeight | private void calculateValueTextHeight() {
Rect valueRect = new Rect();
Rect legendRect = new Rect();
String str = Utils.getFloatString(mFocusedPoint.getValue(), mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? " " + mIndicatorTextUnit : "");
// calculate the boundaries for both texts
mIndicatorPaint.getTextBounds(str, 0, str.length(), valueRect);
mLegendPaint.getTextBounds(mFocusedPoint.getLegendLabel(), 0, mFocusedPoint.getLegendLabel().length(), legendRect);
// calculate string positions in overlay
mValueTextHeight = valueRect.height();
mValueLabelY = (int) (mValueTextHeight + mIndicatorTopPadding);
mLegendLabelY = (int) (mValueTextHeight + mIndicatorTopPadding + legendRect.height() + Utils.dpToPx(7.f));
int chosenWidth = valueRect.width() > legendRect.width() ? valueRect.width() : legendRect.width();
// check if text reaches over screen
if (mFocusedPoint.getCoordinates().getX() + chosenWidth + mIndicatorLeftPadding > -Utils.getTranslationX(mDrawMatrixValues) + mGraphWidth) {
mValueLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (valueRect.width() + mIndicatorLeftPadding));
mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (legendRect.width() + mIndicatorLeftPadding));
} else {
mValueLabelX = mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding);
}
} | java | private void calculateValueTextHeight() {
Rect valueRect = new Rect();
Rect legendRect = new Rect();
String str = Utils.getFloatString(mFocusedPoint.getValue(), mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? " " + mIndicatorTextUnit : "");
// calculate the boundaries for both texts
mIndicatorPaint.getTextBounds(str, 0, str.length(), valueRect);
mLegendPaint.getTextBounds(mFocusedPoint.getLegendLabel(), 0, mFocusedPoint.getLegendLabel().length(), legendRect);
// calculate string positions in overlay
mValueTextHeight = valueRect.height();
mValueLabelY = (int) (mValueTextHeight + mIndicatorTopPadding);
mLegendLabelY = (int) (mValueTextHeight + mIndicatorTopPadding + legendRect.height() + Utils.dpToPx(7.f));
int chosenWidth = valueRect.width() > legendRect.width() ? valueRect.width() : legendRect.width();
// check if text reaches over screen
if (mFocusedPoint.getCoordinates().getX() + chosenWidth + mIndicatorLeftPadding > -Utils.getTranslationX(mDrawMatrixValues) + mGraphWidth) {
mValueLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (valueRect.width() + mIndicatorLeftPadding));
mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (legendRect.width() + mIndicatorLeftPadding));
} else {
mValueLabelX = mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding);
}
} | [
"private",
"void",
"calculateValueTextHeight",
"(",
")",
"{",
"Rect",
"valueRect",
"=",
"new",
"Rect",
"(",
")",
";",
"Rect",
"legendRect",
"=",
"new",
"Rect",
"(",
")",
";",
"String",
"str",
"=",
"Utils",
".",
"getFloatString",
"(",
"mFocusedPoint",
".",
... | Calculates the text height for the indicator value and sets its x-coordinate. | [
"Calculates",
"the",
"text",
"height",
"for",
"the",
"indicator",
"value",
"and",
"sets",
"its",
"x",
"-",
"coordinate",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java#L977-L1000 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java | BaseBarChart.calculateBarPositions | protected void calculateBarPositions(int _DataSize) {
int dataSize = mScrollEnabled ? mVisibleBars : _DataSize;
float barWidth = mBarWidth;
float margin = mBarMargin;
if (!mFixedBarWidth) {
// calculate the bar width if the bars should be dynamically displayed
barWidth = (mAvailableScreenSize / _DataSize) - margin;
} else {
if(_DataSize < mVisibleBars) {
dataSize = _DataSize;
}
// calculate margin between bars if the bars have a fixed width
float cumulatedBarWidths = barWidth * dataSize;
float remainingScreenSize = mAvailableScreenSize - cumulatedBarWidths;
margin = remainingScreenSize / dataSize;
}
boolean isVertical = this instanceof VerticalBarChart;
int calculatedSize = (int) ((barWidth * _DataSize) + (margin * _DataSize));
int contentWidth = isVertical ? mGraphWidth : calculatedSize;
int contentHeight = isVertical ? calculatedSize : mGraphHeight;
mContentRect = new Rect(0, 0, contentWidth, contentHeight);
mCurrentViewport = new RectF(0, 0, mGraphWidth, mGraphHeight);
calculateBounds(barWidth, margin);
mLegend.invalidate();
mGraph.invalidate();
} | java | protected void calculateBarPositions(int _DataSize) {
int dataSize = mScrollEnabled ? mVisibleBars : _DataSize;
float barWidth = mBarWidth;
float margin = mBarMargin;
if (!mFixedBarWidth) {
// calculate the bar width if the bars should be dynamically displayed
barWidth = (mAvailableScreenSize / _DataSize) - margin;
} else {
if(_DataSize < mVisibleBars) {
dataSize = _DataSize;
}
// calculate margin between bars if the bars have a fixed width
float cumulatedBarWidths = barWidth * dataSize;
float remainingScreenSize = mAvailableScreenSize - cumulatedBarWidths;
margin = remainingScreenSize / dataSize;
}
boolean isVertical = this instanceof VerticalBarChart;
int calculatedSize = (int) ((barWidth * _DataSize) + (margin * _DataSize));
int contentWidth = isVertical ? mGraphWidth : calculatedSize;
int contentHeight = isVertical ? calculatedSize : mGraphHeight;
mContentRect = new Rect(0, 0, contentWidth, contentHeight);
mCurrentViewport = new RectF(0, 0, mGraphWidth, mGraphHeight);
calculateBounds(barWidth, margin);
mLegend.invalidate();
mGraph.invalidate();
} | [
"protected",
"void",
"calculateBarPositions",
"(",
"int",
"_DataSize",
")",
"{",
"int",
"dataSize",
"=",
"mScrollEnabled",
"?",
"mVisibleBars",
":",
"_DataSize",
";",
"float",
"barWidth",
"=",
"mBarWidth",
";",
"float",
"margin",
"=",
"mBarMargin",
";",
"if",
... | Calculates the bar width and bar margin based on the _DataSize and settings and starts the boundary
calculation in child classes.
@param _DataSize Amount of data sets | [
"Calculates",
"the",
"bar",
"width",
"and",
"bar",
"margin",
"based",
"on",
"the",
"_DataSize",
"and",
"settings",
"and",
"starts",
"the",
"boundary",
"calculation",
"in",
"child",
"classes",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java#L322-L356 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java | BaseBarChart.onGraphDraw | @Override
protected void onGraphDraw(Canvas _Canvas) {
super.onGraphDraw(_Canvas);
_Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top);
drawBars(_Canvas);
} | java | @Override
protected void onGraphDraw(Canvas _Canvas) {
super.onGraphDraw(_Canvas);
_Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top);
drawBars(_Canvas);
} | [
"@",
"Override",
"protected",
"void",
"onGraphDraw",
"(",
"Canvas",
"_Canvas",
")",
"{",
"super",
".",
"onGraphDraw",
"(",
"_Canvas",
")",
";",
"_Canvas",
".",
"translate",
"(",
"-",
"mCurrentViewport",
".",
"left",
",",
"-",
"mCurrentViewport",
".",
"top",
... | region Override Methods | [
"region",
"Override",
"Methods"
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java#L467-L472 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java | Utils.calculatePointDiff | public static void calculatePointDiff(Point2D _P1, Point2D _P2, Point2D _Result, float _Multiplier) {
float diffX = _P2.getX() - _P1.getX();
float diffY = _P2.getY() - _P1.getY();
_Result.setX(_P1.getX() + (diffX * _Multiplier));
_Result.setY(_P1.getY() + (diffY * _Multiplier));
} | java | public static void calculatePointDiff(Point2D _P1, Point2D _P2, Point2D _Result, float _Multiplier) {
float diffX = _P2.getX() - _P1.getX();
float diffY = _P2.getY() - _P1.getY();
_Result.setX(_P1.getX() + (diffX * _Multiplier));
_Result.setY(_P1.getY() + (diffY * _Multiplier));
} | [
"public",
"static",
"void",
"calculatePointDiff",
"(",
"Point2D",
"_P1",
",",
"Point2D",
"_P2",
",",
"Point2D",
"_Result",
",",
"float",
"_Multiplier",
")",
"{",
"float",
"diffX",
"=",
"_P2",
".",
"getX",
"(",
")",
"-",
"_P1",
".",
"getX",
"(",
")",
";... | Calculates the middle point between two points and multiplies its coordinates with the given
smoothness _Mulitplier.
@param _P1 First point
@param _P2 Second point
@param _Result Resulting point
@param _Multiplier Smoothness multiplier | [
"Calculates",
"the",
"middle",
"point",
"between",
"two",
"points",
"and",
"multiplies",
"its",
"coordinates",
"with",
"the",
"given",
"smoothness",
"_Mulitplier",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L58-L63 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java | Utils.calculateLegendInformation | public static void calculateLegendInformation(List<? extends BaseModel> _Models, float _StartX, float _EndX, Paint _Paint) {
float textMargin = Utils.dpToPx(10.f);
float lastX = _StartX;
// calculate the legend label positions and check if there is enough space to display the label,
// if not the label will not be shown
for (BaseModel model : _Models) {
if (!model.isIgnore()) {
Rect textBounds = new Rect();
RectF legendBounds = model.getLegendBounds();
_Paint.getTextBounds(model.getLegendLabel(), 0, model.getLegendLabel().length(), textBounds);
model.setTextBounds(textBounds);
float centerX = legendBounds.centerX();
float centeredTextPos = centerX - (textBounds.width() / 2);
float textStartPos = centeredTextPos - textMargin;
// check if the text is too big to fit on the screen
if (centeredTextPos + textBounds.width() > _EndX - textMargin) {
model.setShowLabel(false);
} else {
// check if the current legend label overrides the label before
// if the label overrides the label before, the current label will not be shown.
// If not the label will be shown and the label position is calculated
if (textStartPos < lastX) {
if (lastX + textMargin < legendBounds.left) {
model.setLegendLabelPosition((int) (lastX + textMargin));
model.setShowLabel(true);
lastX = lastX + textMargin + textBounds.width();
} else {
model.setShowLabel(false);
}
} else {
model.setShowLabel(true);
model.setLegendLabelPosition((int) centeredTextPos);
lastX = centerX + (textBounds.width() / 2);
}
}
}
}
} | java | public static void calculateLegendInformation(List<? extends BaseModel> _Models, float _StartX, float _EndX, Paint _Paint) {
float textMargin = Utils.dpToPx(10.f);
float lastX = _StartX;
// calculate the legend label positions and check if there is enough space to display the label,
// if not the label will not be shown
for (BaseModel model : _Models) {
if (!model.isIgnore()) {
Rect textBounds = new Rect();
RectF legendBounds = model.getLegendBounds();
_Paint.getTextBounds(model.getLegendLabel(), 0, model.getLegendLabel().length(), textBounds);
model.setTextBounds(textBounds);
float centerX = legendBounds.centerX();
float centeredTextPos = centerX - (textBounds.width() / 2);
float textStartPos = centeredTextPos - textMargin;
// check if the text is too big to fit on the screen
if (centeredTextPos + textBounds.width() > _EndX - textMargin) {
model.setShowLabel(false);
} else {
// check if the current legend label overrides the label before
// if the label overrides the label before, the current label will not be shown.
// If not the label will be shown and the label position is calculated
if (textStartPos < lastX) {
if (lastX + textMargin < legendBounds.left) {
model.setLegendLabelPosition((int) (lastX + textMargin));
model.setShowLabel(true);
lastX = lastX + textMargin + textBounds.width();
} else {
model.setShowLabel(false);
}
} else {
model.setShowLabel(true);
model.setLegendLabelPosition((int) centeredTextPos);
lastX = centerX + (textBounds.width() / 2);
}
}
}
}
} | [
"public",
"static",
"void",
"calculateLegendInformation",
"(",
"List",
"<",
"?",
"extends",
"BaseModel",
">",
"_Models",
",",
"float",
"_StartX",
",",
"float",
"_EndX",
",",
"Paint",
"_Paint",
")",
"{",
"float",
"textMargin",
"=",
"Utils",
".",
"dpToPx",
"("... | Calculates the legend positions and which legend title should be displayed or not.
Important: the LegendBounds in the _Models should be set and correctly calculated before this
function is called!
@param _Models The graph data which should have the BaseModel class as parent class.
@param _StartX Left starting point on the screen. Should be the absolute pixel value!
@param _Paint The correctly set Paint which will be used for the text painting in the later process | [
"Calculates",
"the",
"legend",
"positions",
"and",
"which",
"legend",
"title",
"should",
"be",
"displayed",
"or",
"not",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L98-L140 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java | Utils.calculateMaxTextHeight | public static float calculateMaxTextHeight(Paint _Paint, String _Text) {
Rect height = new Rect();
String text = _Text == null ? "MgHITasger" : _Text;
_Paint.getTextBounds(text, 0, text.length(), height);
return height.height();
} | java | public static float calculateMaxTextHeight(Paint _Paint, String _Text) {
Rect height = new Rect();
String text = _Text == null ? "MgHITasger" : _Text;
_Paint.getTextBounds(text, 0, text.length(), height);
return height.height();
} | [
"public",
"static",
"float",
"calculateMaxTextHeight",
"(",
"Paint",
"_Paint",
",",
"String",
"_Text",
")",
"{",
"Rect",
"height",
"=",
"new",
"Rect",
"(",
")",
";",
"String",
"text",
"=",
"_Text",
"==",
"null",
"?",
"\"MgHITasger\"",
":",
"_Text",
";",
... | Calculates the maximum text height which is possible based on the used Paint and its settings.
@param _Paint Paint object which will be used to display a text.
@param _Text The text which should be measured. If null, a default text is chosen, which
has a maximum possible height
@return Maximum text height in px. | [
"Calculates",
"the",
"maximum",
"text",
"height",
"which",
"is",
"possible",
"based",
"on",
"the",
"used",
"Paint",
"and",
"its",
"settings",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L165-L170 | train |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java | Utils.intersectsPointWithRectF | public static boolean intersectsPointWithRectF(RectF _Rect, float _X, float _Y) {
return _X > _Rect.left && _X < _Rect.right && _Y > _Rect.top && _Y < _Rect.bottom;
} | java | public static boolean intersectsPointWithRectF(RectF _Rect, float _X, float _Y) {
return _X > _Rect.left && _X < _Rect.right && _Y > _Rect.top && _Y < _Rect.bottom;
} | [
"public",
"static",
"boolean",
"intersectsPointWithRectF",
"(",
"RectF",
"_Rect",
",",
"float",
"_X",
",",
"float",
"_Y",
")",
"{",
"return",
"_X",
">",
"_Rect",
".",
"left",
"&&",
"_X",
"<",
"_Rect",
".",
"right",
"&&",
"_Y",
">",
"_Rect",
".",
"top",... | Checks if a point is in the given rectangle.
@param _Rect rectangle which is checked
@param _X x-coordinate of the point
@param _Y y-coordinate of the point
@return True if the points intersects with the rectangle. | [
"Checks",
"if",
"a",
"point",
"is",
"in",
"the",
"given",
"rectangle",
"."
] | ce5e68ecc70e154f83bbb2fcce1a970db125c1e6 | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L180-L182 | train |
airbnb/AirMapView | library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java | RuntimePermissionUtils.hasSelfPermissions | private static boolean hasSelfPermissions(Context context, String... permissions) {
for (String permission : permissions) {
if (checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
return true;
}
}
return false;
} | java | private static boolean hasSelfPermissions(Context context, String... permissions) {
for (String permission : permissions) {
if (checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"hasSelfPermissions",
"(",
"Context",
"context",
",",
"String",
"...",
"permissions",
")",
"{",
"for",
"(",
"String",
"permission",
":",
"permissions",
")",
"{",
"if",
"(",
"checkSelfPermission",
"(",
"context",
",",
"permission",... | Returns true if the context has access to any given permissions. | [
"Returns",
"true",
"if",
"the",
"context",
"has",
"access",
"to",
"any",
"given",
"permissions",
"."
] | f715197db2cc2903e8d70f78385d339c3f6a1c3b | https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java#L41-L48 | train |
airbnb/AirMapView | library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java | RuntimePermissionUtils.shouldShowRequestPermissionRationale | static boolean shouldShowRequestPermissionRationale(Activity activity, String... permissions) {
for (String permission : permissions) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
return true;
}
}
return false;
} | java | static boolean shouldShowRequestPermissionRationale(Activity activity, String... permissions) {
for (String permission : permissions) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
return true;
}
}
return false;
} | [
"static",
"boolean",
"shouldShowRequestPermissionRationale",
"(",
"Activity",
"activity",
",",
"String",
"...",
"permissions",
")",
"{",
"for",
"(",
"String",
"permission",
":",
"permissions",
")",
"{",
"if",
"(",
"ActivityCompat",
".",
"shouldShowRequestPermissionRat... | Checks given permissions are needed to show rationale.
@return returns true if one of the permission is needed to show rationale. | [
"Checks",
"given",
"permissions",
"are",
"needed",
"to",
"show",
"rationale",
"."
] | f715197db2cc2903e8d70f78385d339c3f6a1c3b | https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java#L55-L62 | train |
airbnb/AirMapView | library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java | DefaultAirMapViewBuilder.builder | public AirMapViewBuilder builder(AirMapViewTypes mapType) {
switch (mapType) {
case NATIVE:
if (isNativeMapSupported) {
return new NativeAirMapViewBuilder();
}
break;
case WEB:
return getWebMapViewBuilder();
}
throw new UnsupportedOperationException("Requested map type is not supported");
} | java | public AirMapViewBuilder builder(AirMapViewTypes mapType) {
switch (mapType) {
case NATIVE:
if (isNativeMapSupported) {
return new NativeAirMapViewBuilder();
}
break;
case WEB:
return getWebMapViewBuilder();
}
throw new UnsupportedOperationException("Requested map type is not supported");
} | [
"public",
"AirMapViewBuilder",
"builder",
"(",
"AirMapViewTypes",
"mapType",
")",
"{",
"switch",
"(",
"mapType",
")",
"{",
"case",
"NATIVE",
":",
"if",
"(",
"isNativeMapSupported",
")",
"{",
"return",
"new",
"NativeAirMapViewBuilder",
"(",
")",
";",
"}",
"brea... | Returns the AirMapView implementation as requested by the mapType argument. Use this method if
you need to request a specific AirMapView implementation that is not necessarily the preferred
type. For example, you can use it to explicit request a web-based map implementation.
@param mapType Map type for the requested AirMapView implementation.
@return An {@link AirMapViewBuilder} for the requested {@link AirMapViewTypes} mapType. | [
"Returns",
"the",
"AirMapView",
"implementation",
"as",
"requested",
"by",
"the",
"mapType",
"argument",
".",
"Use",
"this",
"method",
"if",
"you",
"need",
"to",
"request",
"a",
"specific",
"AirMapView",
"implementation",
"that",
"is",
"not",
"necessarily",
"the... | f715197db2cc2903e8d70f78385d339c3f6a1c3b | https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java#L60-L71 | train |
airbnb/AirMapView | library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java | DefaultAirMapViewBuilder.getWebMapViewBuilder | private AirMapViewBuilder getWebMapViewBuilder() {
if (context != null) {
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String accessToken = bundle.getString("com.mapbox.ACCESS_TOKEN");
String mapId = bundle.getString("com.mapbox.MAP_ID");
if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(mapId)) {
return new MapboxWebMapViewBuilder(accessToken, mapId);
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to load Mapbox access token and map id", e);
}
}
return new WebAirMapViewBuilder();
} | java | private AirMapViewBuilder getWebMapViewBuilder() {
if (context != null) {
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String accessToken = bundle.getString("com.mapbox.ACCESS_TOKEN");
String mapId = bundle.getString("com.mapbox.MAP_ID");
if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(mapId)) {
return new MapboxWebMapViewBuilder(accessToken, mapId);
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to load Mapbox access token and map id", e);
}
}
return new WebAirMapViewBuilder();
} | [
"private",
"AirMapViewBuilder",
"getWebMapViewBuilder",
"(",
")",
"{",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"try",
"{",
"ApplicationInfo",
"ai",
"=",
"context",
".",
"getPackageManager",
"(",
")",
".",
"getApplicationInfo",
"(",
"context",
".",
"getPa... | Decides what the Map Web provider should be used and generates a builder for it.
@return The AirMapViewBuilder for the selected Map Web provider. | [
"Decides",
"what",
"the",
"Map",
"Web",
"provider",
"should",
"be",
"used",
"and",
"generates",
"a",
"builder",
"for",
"it",
"."
] | f715197db2cc2903e8d70f78385d339c3f6a1c3b | https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java#L78-L95 | train |
airbnb/AirMapView | library/src/main/java/com/airbnb/android/airmapview/AirMapView.java | AirMapView.initialize | public void initialize(FragmentManager fragmentManager) {
AirMapInterface mapInterface = (AirMapInterface)
fragmentManager.findFragmentById(R.id.map_frame);
if (mapInterface != null) {
initialize(fragmentManager, mapInterface);
} else {
initialize(fragmentManager, new DefaultAirMapViewBuilder(getContext()).builder().build());
}
} | java | public void initialize(FragmentManager fragmentManager) {
AirMapInterface mapInterface = (AirMapInterface)
fragmentManager.findFragmentById(R.id.map_frame);
if (mapInterface != null) {
initialize(fragmentManager, mapInterface);
} else {
initialize(fragmentManager, new DefaultAirMapViewBuilder(getContext()).builder().build());
}
} | [
"public",
"void",
"initialize",
"(",
"FragmentManager",
"fragmentManager",
")",
"{",
"AirMapInterface",
"mapInterface",
"=",
"(",
"AirMapInterface",
")",
"fragmentManager",
".",
"findFragmentById",
"(",
"R",
".",
"id",
".",
"map_frame",
")",
";",
"if",
"(",
"map... | Used for initialization of the underlying map provider.
@param fragmentManager required for initialization | [
"Used",
"for",
"initialization",
"of",
"the",
"underlying",
"map",
"provider",
"."
] | f715197db2cc2903e8d70f78385d339c3f6a1c3b | https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/AirMapView.java#L85-L94 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java | PropertyAccessor.getFieldAnnotations | private Set<Annotation> getFieldAnnotations(final Class<?> clazz)
{
try
{
return new LinkedHashSet<Annotation>(asList(clazz.getDeclaredField(propertyName).getAnnotations()));
}
catch (final NoSuchFieldException e)
{
if (clazz.getSuperclass() != null)
{
return getFieldAnnotations(clazz.getSuperclass());
}
else
{
logger.debug("Cannot find propertyName: {}, declaring class: {}", propertyName, clazz);
return new LinkedHashSet<Annotation>(0);
}
}
} | java | private Set<Annotation> getFieldAnnotations(final Class<?> clazz)
{
try
{
return new LinkedHashSet<Annotation>(asList(clazz.getDeclaredField(propertyName).getAnnotations()));
}
catch (final NoSuchFieldException e)
{
if (clazz.getSuperclass() != null)
{
return getFieldAnnotations(clazz.getSuperclass());
}
else
{
logger.debug("Cannot find propertyName: {}, declaring class: {}", propertyName, clazz);
return new LinkedHashSet<Annotation>(0);
}
}
} | [
"private",
"Set",
"<",
"Annotation",
">",
"getFieldAnnotations",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"try",
"{",
"return",
"new",
"LinkedHashSet",
"<",
"Annotation",
">",
"(",
"asList",
"(",
"clazz",
".",
"getDeclaredField",
"(",
"prop... | Private function to allow looking for the field recursively up the superclasses.
@param clazz
@return | [
"Private",
"function",
"to",
"allow",
"looking",
"for",
"the",
"field",
"recursively",
"up",
"the",
"superclasses",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java#L92-L110 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/ObjectDiffer.java | ObjectDiffer.compare | public <T> DiffNode compare(final T working, final T base)
{
dispatcher.resetInstanceMemory();
try
{
return dispatcher.dispatch(DiffNode.ROOT, Instances.of(working, base), RootAccessor.getInstance());
}
finally
{
dispatcher.clearInstanceMemory();
}
} | java | public <T> DiffNode compare(final T working, final T base)
{
dispatcher.resetInstanceMemory();
try
{
return dispatcher.dispatch(DiffNode.ROOT, Instances.of(working, base), RootAccessor.getInstance());
}
finally
{
dispatcher.clearInstanceMemory();
}
} | [
"public",
"<",
"T",
">",
"DiffNode",
"compare",
"(",
"final",
"T",
"working",
",",
"final",
"T",
"base",
")",
"{",
"dispatcher",
".",
"resetInstanceMemory",
"(",
")",
";",
"try",
"{",
"return",
"dispatcher",
".",
"dispatch",
"(",
"DiffNode",
".",
"ROOT",... | Recursively inspects the given objects and returns a node representing their differences. Both objects
have be have the same type.
@param working This object will be treated as the successor of the `base` object.
@param base This object will be treated as the predecessor of the <code>working</code> object.
@return A node representing the differences between the given objects. | [
"Recursively",
"inspects",
"the",
"given",
"objects",
"and",
"returns",
"a",
"node",
"representing",
"their",
"differences",
".",
"Both",
"objects",
"have",
"be",
"have",
"the",
"same",
"type",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/ObjectDiffer.java#L47-L58 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.getChild | public DiffNode getChild(final NodePath nodePath)
{
if (parentNode != null)
{
return parentNode.getChild(nodePath.getElementSelectors());
}
else
{
return getChild(nodePath.getElementSelectors());
}
} | java | public DiffNode getChild(final NodePath nodePath)
{
if (parentNode != null)
{
return parentNode.getChild(nodePath.getElementSelectors());
}
else
{
return getChild(nodePath.getElementSelectors());
}
} | [
"public",
"DiffNode",
"getChild",
"(",
"final",
"NodePath",
"nodePath",
")",
"{",
"if",
"(",
"parentNode",
"!=",
"null",
")",
"{",
"return",
"parentNode",
".",
"getChild",
"(",
"nodePath",
".",
"getElementSelectors",
"(",
")",
")",
";",
"}",
"else",
"{",
... | Retrieve a child that matches the given absolute path, starting from the current node.
@param nodePath The path from the object root to the requested child node.
@return The requested child node or <code>null</code>. | [
"Retrieve",
"a",
"child",
"that",
"matches",
"the",
"given",
"absolute",
"path",
"starting",
"from",
"the",
"current",
"node",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L307-L317 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.addChild | public void addChild(final DiffNode node)
{
if (node == this)
{
throw new IllegalArgumentException("Detected attempt to add a node to itself. " +
"This would cause inifite loops and must never happen.");
}
else if (node.isRootNode())
{
throw new IllegalArgumentException("Detected attempt to add root node as child. " +
"This is not allowed and must be a mistake.");
}
else if (node.getParentNode() != null && node.getParentNode() != this)
{
throw new IllegalArgumentException("Detected attempt to add child node that is already the " +
"child of another node. Adding nodes multiple times is not allowed, since it could " +
"cause infinite loops.");
}
if (node.getParentNode() == null)
{
node.setParentNode(this);
}
children.put(node.getElementSelector(), node);
if (state == State.UNTOUCHED && node.hasChanges())
{
state = State.CHANGED;
}
} | java | public void addChild(final DiffNode node)
{
if (node == this)
{
throw new IllegalArgumentException("Detected attempt to add a node to itself. " +
"This would cause inifite loops and must never happen.");
}
else if (node.isRootNode())
{
throw new IllegalArgumentException("Detected attempt to add root node as child. " +
"This is not allowed and must be a mistake.");
}
else if (node.getParentNode() != null && node.getParentNode() != this)
{
throw new IllegalArgumentException("Detected attempt to add child node that is already the " +
"child of another node. Adding nodes multiple times is not allowed, since it could " +
"cause infinite loops.");
}
if (node.getParentNode() == null)
{
node.setParentNode(this);
}
children.put(node.getElementSelector(), node);
if (state == State.UNTOUCHED && node.hasChanges())
{
state = State.CHANGED;
}
} | [
"public",
"void",
"addChild",
"(",
"final",
"DiffNode",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"this",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Detected attempt to add a node to itself. \"",
"+",
"\"This would cause inifite loops and must never ha... | Adds a child to this node and sets this node as its parent node.
@param node The node to add. | [
"Adds",
"a",
"child",
"to",
"this",
"node",
"and",
"sets",
"this",
"node",
"as",
"its",
"parent",
"node",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L364-L391 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.visit | public final void visit(final Visitor visitor)
{
final Visit visit = new Visit();
try
{
visit(visitor, visit);
}
catch (final StopVisitationException ignored)
{
}
} | java | public final void visit(final Visitor visitor)
{
final Visit visit = new Visit();
try
{
visit(visitor, visit);
}
catch (final StopVisitationException ignored)
{
}
} | [
"public",
"final",
"void",
"visit",
"(",
"final",
"Visitor",
"visitor",
")",
"{",
"final",
"Visit",
"visit",
"=",
"new",
"Visit",
"(",
")",
";",
"try",
"{",
"visit",
"(",
"visitor",
",",
"visit",
")",
";",
"}",
"catch",
"(",
"final",
"StopVisitationExc... | Visit this and all child nodes.
@param visitor The visitor to use. | [
"Visit",
"this",
"and",
"all",
"child",
"nodes",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L398-L408 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.visitChildren | public final void visitChildren(final Visitor visitor)
{
for (final DiffNode child : children.values())
{
try
{
child.visit(visitor);
}
catch (final StopVisitationException e)
{
return;
}
}
} | java | public final void visitChildren(final Visitor visitor)
{
for (final DiffNode child : children.values())
{
try
{
child.visit(visitor);
}
catch (final StopVisitationException e)
{
return;
}
}
} | [
"public",
"final",
"void",
"visitChildren",
"(",
"final",
"Visitor",
"visitor",
")",
"{",
"for",
"(",
"final",
"DiffNode",
"child",
":",
"children",
".",
"values",
"(",
")",
")",
"{",
"try",
"{",
"child",
".",
"visit",
"(",
"visitor",
")",
";",
"}",
... | Visit all child nodes but not this one.
@param visitor The visitor to use. | [
"Visit",
"all",
"child",
"nodes",
"but",
"not",
"this",
"one",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L435-L448 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.getPropertyAnnotations | public Set<Annotation> getPropertyAnnotations()
{
if (accessor instanceof PropertyAwareAccessor)
{
return unmodifiableSet(((PropertyAwareAccessor) accessor).getReadMethodAnnotations());
}
return unmodifiableSet(Collections.<Annotation>emptySet());
} | java | public Set<Annotation> getPropertyAnnotations()
{
if (accessor instanceof PropertyAwareAccessor)
{
return unmodifiableSet(((PropertyAwareAccessor) accessor).getReadMethodAnnotations());
}
return unmodifiableSet(Collections.<Annotation>emptySet());
} | [
"public",
"Set",
"<",
"Annotation",
">",
"getPropertyAnnotations",
"(",
")",
"{",
"if",
"(",
"accessor",
"instanceof",
"PropertyAwareAccessor",
")",
"{",
"return",
"unmodifiableSet",
"(",
"(",
"(",
"PropertyAwareAccessor",
")",
"accessor",
")",
".",
"getReadMethod... | If this node represents a bean property this method returns all annotations of its getter.
@return A set of annotations of this nodes property getter or an empty set. | [
"If",
"this",
"node",
"represents",
"a",
"bean",
"property",
"this",
"method",
"returns",
"all",
"annotations",
"of",
"its",
"getter",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L499-L506 | train |
SQiShER/java-object-diff | src/main/java/de/danielbechler/diff/node/DiffNode.java | DiffNode.setParentNode | protected final void setParentNode(final DiffNode parentNode)
{
if (this.parentNode != null && this.parentNode != parentNode)
{
throw new IllegalStateException("The parent of a node cannot be changed, once it's set.");
}
this.parentNode = parentNode;
} | java | protected final void setParentNode(final DiffNode parentNode)
{
if (this.parentNode != null && this.parentNode != parentNode)
{
throw new IllegalStateException("The parent of a node cannot be changed, once it's set.");
}
this.parentNode = parentNode;
} | [
"protected",
"final",
"void",
"setParentNode",
"(",
"final",
"DiffNode",
"parentNode",
")",
"{",
"if",
"(",
"this",
".",
"parentNode",
"!=",
"null",
"&&",
"this",
".",
"parentNode",
"!=",
"parentNode",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
... | Sets the parent node.
@param parentNode The parent of this node. May be null, if this is a root node. | [
"Sets",
"the",
"parent",
"node",
"."
] | 6f576669d49087f0e825a417cadc3d4c707a4924 | https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L616-L623 | train |
uber/tchannel-java | tchannel-hyperbahn/src/main/java/com/uber/tchannel/hyperbahn/api/HyperbahnClient.java | HyperbahnClient.advertise | public TFuture<JsonResponse<AdvertiseResponse>> advertise() {
final AdvertiseRequest advertiseRequest = new AdvertiseRequest();
advertiseRequest.addService(service, 0);
// TODO: options for hard fail, retries etc.
final JsonRequest<AdvertiseRequest> request = new JsonRequest.Builder<AdvertiseRequest>(
HYPERBAHN_SERVICE_NAME,
HYPERBAHN_ADVERTISE_ENDPOINT
)
.setBody(advertiseRequest)
.setTimeout(REQUEST_TIMEOUT)
.setRetryLimit(4)
.build();
final TFuture<JsonResponse<AdvertiseResponse>> future = hyperbahnChannel.send(request);
future.addCallback(new TFutureCallback<JsonResponse<AdvertiseResponse>>() {
@Override
public void onResponse(JsonResponse<AdvertiseResponse> response) {
if (response.isError()) {
logger.error("Failed to advertise to Hyperbahn: {} - {}",
response.getError().getErrorType(),
response.getError().getMessage());
}
if (destroyed.get()) {
return;
}
scheduleAdvertise();
}
});
return future;
} | java | public TFuture<JsonResponse<AdvertiseResponse>> advertise() {
final AdvertiseRequest advertiseRequest = new AdvertiseRequest();
advertiseRequest.addService(service, 0);
// TODO: options for hard fail, retries etc.
final JsonRequest<AdvertiseRequest> request = new JsonRequest.Builder<AdvertiseRequest>(
HYPERBAHN_SERVICE_NAME,
HYPERBAHN_ADVERTISE_ENDPOINT
)
.setBody(advertiseRequest)
.setTimeout(REQUEST_TIMEOUT)
.setRetryLimit(4)
.build();
final TFuture<JsonResponse<AdvertiseResponse>> future = hyperbahnChannel.send(request);
future.addCallback(new TFutureCallback<JsonResponse<AdvertiseResponse>>() {
@Override
public void onResponse(JsonResponse<AdvertiseResponse> response) {
if (response.isError()) {
logger.error("Failed to advertise to Hyperbahn: {} - {}",
response.getError().getErrorType(),
response.getError().getMessage());
}
if (destroyed.get()) {
return;
}
scheduleAdvertise();
}
});
return future;
} | [
"public",
"TFuture",
"<",
"JsonResponse",
"<",
"AdvertiseResponse",
">",
">",
"advertise",
"(",
")",
"{",
"final",
"AdvertiseRequest",
"advertiseRequest",
"=",
"new",
"AdvertiseRequest",
"(",
")",
";",
"advertiseRequest",
".",
"addService",
"(",
"service",
",",
... | Starts advertising on Hyperbahn at a fixed interval.
@return a future that resolves to the response of the first advertise request | [
"Starts",
"advertising",
"on",
"Hyperbahn",
"at",
"a",
"fixed",
"interval",
"."
] | 009cf1e6decc9bbd2daf90eb3401b13c03bfc7e1 | https://github.com/uber/tchannel-java/blob/009cf1e6decc9bbd2daf90eb3401b13c03bfc7e1/tchannel-hyperbahn/src/main/java/com/uber/tchannel/hyperbahn/api/HyperbahnClient.java#L91-L125 | train |
bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java | JsonMapper.parseList | public List<T> parseList(JsonParser jsonParser) throws IOException {
List<T> list = new ArrayList<>();
if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
list.add(parse(jsonParser));
}
}
return list;
} | java | public List<T> parseList(JsonParser jsonParser) throws IOException {
List<T> list = new ArrayList<>();
if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
list.add(parse(jsonParser));
}
}
return list;
} | [
"public",
"List",
"<",
"T",
">",
"parseList",
"(",
"JsonParser",
"jsonParser",
")",
"throws",
"IOException",
"{",
"List",
"<",
"T",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"jsonParser",
".",
"getCurrentToken",
"(",
")",
"=... | Parse a list of objects from a JsonParser.
@param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token. | [
"Parse",
"a",
"list",
"of",
"objects",
"from",
"a",
"JsonParser",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java#L137-L145 | train |
bluelinelabs/LoganSquare | core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java | JsonMapper.parseMap | public Map<String, T> parseMap(JsonParser jsonParser) throws IOException {
HashMap<String, T> map = new HashMap<String, T>();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String key = jsonParser.getText();
jsonParser.nextToken();
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
map.put(key, null);
} else{
map.put(key, parse(jsonParser));
}
}
return map;
} | java | public Map<String, T> parseMap(JsonParser jsonParser) throws IOException {
HashMap<String, T> map = new HashMap<String, T>();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String key = jsonParser.getText();
jsonParser.nextToken();
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
map.put(key, null);
} else{
map.put(key, parse(jsonParser));
}
}
return map;
} | [
"public",
"Map",
"<",
"String",
",",
"T",
">",
"parseMap",
"(",
"JsonParser",
"jsonParser",
")",
"throws",
"IOException",
"{",
"HashMap",
"<",
"String",
",",
"T",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"T",
">",
"(",
")",
";",
"while"... | Parse a map of objects from a JsonParser.
@param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token. | [
"Parse",
"a",
"map",
"of",
"objects",
"from",
"a",
"JsonParser",
"."
] | 6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06 | https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java#L196-L208 | train |
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 | train |
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",
"(",
"para... | 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 | train |
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",
"{",
"mapperF... | 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 | train |
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",
")",
".",
"serial... | 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 | train |
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",
">",
... | 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 | train |
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 | train |
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 | train |
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",
"{... | 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 | train |
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 | train |
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 | train |
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",
"(",... | 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 | train |
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",
"IllegalArgumentExce... | 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 | train |
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 | train |
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",
"="... | 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 | train |
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",
"Ob... | 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 | train |
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",
"... | 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 | train |
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",
"=",
... | 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 | train |
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",
")",
... | 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 | train |
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",... | 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 | train |
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\"",
")",
";",
... | 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 | train |
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",
","... | 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 | train |
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",
... | 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 | train |
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... | 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 | train |
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"... | 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",
"com... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/SingularOps_DDRM.java#L319-L347 | train |
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"... | 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 | train |
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",
"(",
... | 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 | train |
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",
"... | 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 | train |
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",
... | 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 | train |
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",
... | 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 | train |
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",
... | 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 | train |
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",
"("... | 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 | train |
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",
... | 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 | train |
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",
"fa... | 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 | train |
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",
... | 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 | train |
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",
",",
"ma... | 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 | train |
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",
")",
... | 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 | train |
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",
... | 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 | train |
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",
".",
... | 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"... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/DMatrixVisualization.java#L48-L68 | train |
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",
"=... | 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 | train |
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",
"*... | 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 | train |
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 = ... | 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 | train |
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",
... | 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 | train |
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",
"<",
... | 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 | train |
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 | train |
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",
"... | 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",... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/eig/symm/SymmetricQrAlgorithm_DDRM.java#L111-L126 | train |
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",
")",
... | 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 | train |
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",
")",
"{",
... | 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 | train |
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",
"... | 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 | train |
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"... | 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 | train |
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",
"... | 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 | train |
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",
",",
"... | 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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.