target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test(groups = "fast") public void testAddParameter() throws Exception { MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), TestMockRoundtrip.class); trip.addParameter("param", "a"); trip.addParameter("param", "b"); trip.execute(); TestMockRoundtrip bean = trip.getActionBean(TestMockRoundtrip.class); Strin...
public void addParameter(String name, String... value) { if (this.request.getParameterValues(name) == null) { setParameter(name, value); } else { String[] oldValues = this.request.getParameterMap().get(name); String[] combined = new String[oldValues.length + value.length]; System.arraycopy(oldValues, 0, combined, 0, ol...
MockRoundtrip { public void addParameter(String name, String... value) { if (this.request.getParameterValues(name) == null) { setParameter(name, value); } else { String[] oldValues = this.request.getParameterMap().get(name); String[] combined = new String[oldValues.length + value.length]; System.arraycopy(oldValues, 0,...
MockRoundtrip { public void addParameter(String name, String... value) { if (this.request.getParameterValues(name) == null) { setParameter(name, value); } else { String[] oldValues = this.request.getParameterMap().get(name); String[] combined = new String[oldValues.length + value.length]; System.arraycopy(oldValues, 0,...
MockRoundtrip { public void addParameter(String name, String... value) { if (this.request.getParameterValues(name) == null) { setParameter(name, value); } else { String[] oldValues = this.request.getParameterMap().get(name); String[] combined = new String[oldValues.length + value.length]; System.arraycopy(oldValues, 0,...
MockRoundtrip { public void addParameter(String name, String... value) { if (this.request.getParameterValues(name) == null) { setParameter(name, value); } else { String[] oldValues = this.request.getParameterMap().get(name); String[] combined = new String[oldValues.length + value.length]; System.arraycopy(oldValues, 0,...
@Test(groups = "fast") public void testTemporaryRedirect() throws Exception { RedirectResolution resolution = new RedirectResolution("http: MockHttpServletResponse response = new MockHttpServletResponse(); resolution.execute(buildMockServletRequest(), response); Assert.assertEquals(response.getStatus(), HttpServletResp...
@SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStat...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
@Test(groups = "fast") public void parseParenthesesWithoutPercentSign() throws Exception { Number result = getConverter().convert("(80)", Float.class, errors()); Assert.assertEquals(result, new Float(-0.8f)); }
public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targetType.equals( Float.TYPE ) ) { number = new Float( number.floatValue() ); } else if ( targetTy...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
@Test(groups = "fast") public void testTemporaryRedirectWithParameters() throws Exception { RedirectResolution resolution = new RedirectResolution("http: MockHttpServletResponse response = new MockHttpServletResponse(); resolution.execute(buildMockServletRequest(), response); Assert.assertEquals(response.getStatus(), H...
@SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new HttpServletResponseWrapper(response) { @Override public void setStat...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
RedirectResolution extends OnwardResolution<RedirectResolution> { @SuppressWarnings("unchecked") @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (permanent) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response = new Ht...
@Test(groups = "fast") public void parseBasicDouble() throws Exception { Number result = getConverter().convert("0.8%", Double.class, errors()); Assert.assertEquals(result, new Double(0.008)); }
public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targetType.equals( Float.TYPE ) ) { number = new Float( number.floatValue() ); } else if ( targetTy...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
PercentageTypeConverter extends NumberTypeConverterSupport implements TypeConverter<Number> { public Number convert( String input, Class<? extends Number> targetType, Collection<ValidationError> errors ) { Number number = parse( input, errors ); if ( errors.size() == 0 ) { if ( targetType.equals( Float.class ) || targe...
@Test public void checkProperNounsTest() throws IOException { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("Ankara", "Iphone [Pr:ayfon]", "Google [Pr:gugıl]") .build(); TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology); String[] correct = {"Ankara", "ANKARA...
public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { co...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
@Test public void lineIteratorTest2() throws IOException { try (LineIterator li = new SimpleTextReader(multi_line_text_file.getFile()).getLineIterator()) { while (li.hasNext()) { out.println(li.next().toUpperCase()); } } }
public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); }
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } }
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
@Test public void lineIteratorWithConstraint() throws IOException { try (LineIterator li = new SimpleTextReader .Builder(multi_line_text_file.getFile()) .ignoreWhiteSpaceLines() .trim() .build().getLineIterator()) { int i = 0; while (li.hasNext()) { String s = li.next(); if (i == 0) { assertEquals(s, "uno"); } if (i ==...
public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); }
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } }
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
SimpleTextReader implements AutoCloseable { public LineIterator getLineIterator() throws IOException { return new LineIterator(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); SimpleTextReader(String fileNam...
@Test public void logSumTest() throws IOException { double[] aLinear = new double[1000]; double[] bLinear = new double[1000]; for (int i = 0; i < bLinear.length; i++) { aLinear[i] = (double) i / 1000d; bLinear[i] = aLinear[i]; } LogMath.LogSumLookup logSumE = LogMath.LOG_SUM; for (double a : aLinear) { for (double b : ...
public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ? logB : l...
LogMath { public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ...
LogMath { public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ...
LogMath { public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ...
LogMath { public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ...
@Test public void logSumFloatTest() throws IOException { float[] aLinear = new float[1000]; float[] bLinear = new float[1000]; for (int i = 0; i < bLinear.length; i++) { aLinear[i] = (float) i / 1000f; bLinear[i] = aLinear[i]; } for (float a : aLinear) { for (float b : bLinear) { float logSumExpected = (float) Math.log...
public static double log(double base, double val) { return Math.log(val) / Math.log(base); }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static d...
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static d...
@Test public void testLog2() { Assert.assertEquals(2, LogMath.log2(4), 0.0001); Assert.assertEquals(3, LogMath.log2(8), 0.0001); Assert.assertEquals(10, LogMath.log2(1024), 0.0001); Assert.assertEquals(-1, LogMath.log2(0.5), 0.0001); }
public static double log2(double input) { return Math.log(input) * INVERSE_LOG_TWO; }
LogMath { public static double log2(double input) { return Math.log(input) * INVERSE_LOG_TWO; } }
LogMath { public static double log2(double input) { return Math.log(input) * INVERSE_LOG_TWO; } private LogMath(); }
LogMath { public static double log2(double input) { return Math.log(input) * INVERSE_LOG_TWO; } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static double l...
LogMath { public static double log2(double input) { return Math.log(input) * INVERSE_LOG_TWO; } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static double l...
@Test public void linearToLogTest() { LogMath.LinearToLogConverter converter = new LogMath.LinearToLogConverter(Math.E); Assert.assertEquals(Math.log(2), converter.convert(2), 0.00000001d); converter = new LogMath.LinearToLogConverter(10d); Assert.assertEquals(Math.log10(2), converter.convert(2), 0.00000001d); }
public static double log(double base, double val) { return Math.log(val) / Math.log(base); }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); }
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static d...
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } private LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static d...
@Test public void testSum() { float[] da = {1, 2, 0, -1, -3}; float[] da2 = {0.5f, -2, 30, 1, -30}; Assert.assertTrue(inDelta(FloatArrays.sum(da), -1)); Assert.assertTrue(inDelta(FloatArrays.sum(da, da2), new float[]{1.5f, 0, 30, 0, -33})); FloatArrays.addToFirst(da, da2); Assert.assertTrue(inDelta(da, new float[]{1.5f...
public static float sum(float... input) { float sum = 0; for (float v : input) { sum += v; } return sum; }
FloatArrays { public static float sum(float... input) { float sum = 0; for (float v : input) { sum += v; } return sum; } }
FloatArrays { public static float sum(float... input) { float sum = 0; for (float v : input) { sum += v; } return sum; } private FloatArrays(); }
FloatArrays { public static float sum(float... input) { float sum = 0; for (float v : input) { sum += v; } return sum; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); s...
FloatArrays { public static float sum(float... input) { float sum = 0; for (float v : input) { sum += v; } return sum; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); s...
@Test public void addToFirstScaledTest() { float[] da1 = {1, 2, 0, -1, -30}; float[] da2 = {-0.5f, -1, 0, 0.5f, 15}; FloatArrays.addToFirstScaled(da1, da2, 2); Assert.assertEquals(FloatArrays.max(da1), 0f, 0.0001); Assert.assertEquals(FloatArrays.min(da1), 0f, 0.0001); }
public static void addToFirstScaled(float[] first, float[] second, float scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } }
FloatArrays { public static void addToFirstScaled(float[] first, float[] second, float scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } }
FloatArrays { public static void addToFirstScaled(float[] first, float[] second, float scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private FloatArrays(); }
FloatArrays { public static void addToFirstScaled(float[] first, float[] second, float scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(flo...
FloatArrays { public static void addToFirstScaled(float[] first, float[] second, float scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(flo...
@Test public void testDotProduct() { float[] da = {1, 2, 0, -1, -3}; float[] da2 = {0.5f, -2, 30, 1, -30}; Assert.assertTrue(inDelta(FloatArrays.dotProduct(da, da2), 85.5f)); }
public static float dotProduct(float[] a1, float[] a2) { return sum(multiply(a1, a2)); }
FloatArrays { public static float dotProduct(float[] a1, float[] a2) { return sum(multiply(a1, a2)); } }
FloatArrays { public static float dotProduct(float[] a1, float[] a2) { return sum(multiply(a1, a2)); } private FloatArrays(); }
FloatArrays { public static float dotProduct(float[] a1, float[] a2) { return sum(multiply(a1, a2)); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static float[] conv...
FloatArrays { public static float dotProduct(float[] a1, float[] a2) { return sum(multiply(a1, a2)); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static float[] conv...
@Test public void testAppendZeros() { float[] da = {1, 2, 0, -1, -3}; float[] da2 = {1, 2, 0, -1, -3, 0, 0, 0, 0, 0, 0}; Assert.assertTrue(inDelta(FloatArrays.appendZeros(da, 6), da2)); Assert.assertTrue(inDelta(FloatArrays.appendZeros(da2, 0), da2)); }
public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); }
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } }
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
@Test public void testGeneration2() { WordGenerator wordGenerator = new WordGenerator(getMorphotactics("elma")); List<String> morphemes = Lists.newArrayList("Noun", "A3pl", "P1pl"); List<Result> results = wordGenerator.generate( "elma", morphemes ); Assert.assertTrue(results.size() > 0); Assert.assertEquals("elmalarımı...
public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPrefixMatches(stem...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
@Test(expected = IllegalArgumentException.class) public void testAppendZerosExc() { float[] da = {1, 2, 0, -1, -3}; FloatArrays.appendZeros(da, -10); }
public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); }
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } }
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
FloatArrays { public static float[] appendZeros(float[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private FloatArrays(...
@Test public void testSquare() { float[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(FloatArrays.square(da), new float[]{1, 4, 0, 1, 9})); }
public static float[] square(float... input) { float[] res = new float[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; }
FloatArrays { public static float[] square(float... input) { float[] res = new float[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } }
FloatArrays { public static float[] square(float... input) { float[] res = new float[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private FloatArrays(); }
FloatArrays { public static float[] square(float... input) { float[] res = new float[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[...
FloatArrays { public static float[] square(float... input) { float[] res = new float[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[...
@Test public void testSquaredSum() { float[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(FloatArrays.squaredSum(da), 15)); float[] da2 = {0, 1, 1, -2, 1}; Assert.assertTrue(inDelta(FloatArrays.squaredSumOfDifferences(da, da2), 20)); Assert.assertTrue(inDelta(FloatArrays.absoluteDifference(da, da2), new float[]{1,...
public static float squaredSum(float[] array) { float result = 0; validateArray(array); for (float a : array) { result += a * a; } return result; }
FloatArrays { public static float squaredSum(float[] array) { float result = 0; validateArray(array); for (float a : array) { result += a * a; } return result; } }
FloatArrays { public static float squaredSum(float[] array) { float result = 0; validateArray(array); for (float a : array) { result += a * a; } return result; } private FloatArrays(); }
FloatArrays { public static float squaredSum(float[] array) { float result = 0; validateArray(array); for (float a : array) { result += a * a; } return result; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); s...
FloatArrays { public static float squaredSum(float[] array) { float result = 0; validateArray(array); for (float a : array) { result += a * a; } return result; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); s...
@Test public void testMean() { float[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(FloatArrays.mean(da), -1f / 5f)); }
public static float mean(float... input) { validateArray(input); return sum(input) / input.length; }
FloatArrays { public static float mean(float... input) { validateArray(input); return sum(input) / input.length; } }
FloatArrays { public static float mean(float... input) { validateArray(input); return sum(input) / input.length; } private FloatArrays(); }
FloatArrays { public static float mean(float... input) { validateArray(input); return sum(input) / input.length; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static ...
FloatArrays { public static float mean(float... input) { validateArray(input); return sum(input) / input.length; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static ...
@Test public void testInRange() { float d = 3; float d2 = 2.5f; float d3 = 7; Assert.assertTrue(FloatArrays.inRange(d, d2, 1)); Assert.assertFalse(FloatArrays.inRange(d2, d3, 4)); Assert.assertTrue(FloatArrays.inRange(d, d2, 0.5f)); }
public static boolean inRange(float d1, float d2, float range) { return Math.abs(d1 - d2) <= range; }
FloatArrays { public static boolean inRange(float d1, float d2, float range) { return Math.abs(d1 - d2) <= range; } }
FloatArrays { public static boolean inRange(float d1, float d2, float range) { return Math.abs(d1 - d2) <= range; } private FloatArrays(); }
FloatArrays { public static boolean inRange(float d1, float d2, float range) { return Math.abs(d1 - d2) <= range; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static...
FloatArrays { public static boolean inRange(float d1, float d2, float range) { return Math.abs(d1 - d2) <= range; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static...
@Test public void testReverse() { float[] da = {1, 3, 7, 2.5f, 0}; float[] da2 = FloatArrays.reverse(FloatArrays.reverse(da)); Assert.assertNotNull(da2); Assert.assertEquals(da.length, da2.length); Assert.assertTrue(inDelta(da, da2)); }
public static float[] reverse(float[] input) { float[] result = new float[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; }
FloatArrays { public static float[] reverse(float[] input) { float[] result = new float[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } }
FloatArrays { public static float[] reverse(float[] input) { float[] result = new float[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private FloatArrays(); }
FloatArrays { public static float[] reverse(float[] input) { float[] result = new float[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] inpu...
FloatArrays { public static float[] reverse(float[] input) { float[] result = new float[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] inpu...
@Test public void testConvertInt() { int[] ia = {1, 3, -1, 0, 9, 12}; float[] da2 = {1, 3, -1, 0, 9.0f, 12.0f}; float[] da = FloatArrays.convert(ia); Assert.assertNotNull(da); Assert.assertTrue(inDelta(da, da2)); }
public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
@Test public void testConvert2f() { int[][] ia = {{1, 2}, {4, 3}, {-1, 5}}; float[][] da = {{1, 2}, {4, 3}, {-1, 5}}; float[][] da2 = FloatArrays.convert(ia); Assert.assertEquals(ia.length, da2.length); Assert.assertNotNull(da2); int k = 0; for (float[] i : da) { int j = 0; for (float ii : i) { Assert.assertEquals(da2[...
public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); }
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
FloatArrays { public static float[] convert(int[] input) { float[] data = new float[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
@Test public void testArrayEqualsInRange() { float[] da = {0, 3.5f, 7, -2, 19}; float[] da2 = {0, 4.5f, 4, 2, -18}; Assert.assertTrue(FloatArrays.arrayEqualsInRange(da, da2, 37)); Assert.assertFalse(FloatArrays.arrayEqualsInRange(da, da2, 15)); Assert.assertTrue(FloatArrays.arrayEqualsInRange(da, da2, 45)); }
public static boolean arrayEqualsInRange(float[] d1, float[] d2, float range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; }
FloatArrays { public static boolean arrayEqualsInRange(float[] d1, float[] d2, float range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } }
FloatArrays { public static boolean arrayEqualsInRange(float[] d1, float[] d2, float range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private FloatArrays(); }
FloatArrays { public static boolean arrayEqualsInRange(float[] d1, float[] d2, float range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static floa...
FloatArrays { public static boolean arrayEqualsInRange(float[] d1, float[] d2, float range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static floa...
@Test public void testArrayEquals() { float[] da = {-1, 0, 3.4f, 7}; float[] da2 = {-1, 0.0f, 3.4f, 7}; float[] da3 = {7, 9.0f, 12.3f, -5.6f}; Assert.assertTrue(FloatArrays.arrayEquals(da, da2)); Assert.assertFalse(FloatArrays.arrayEquals(da2, da3)); }
public static boolean arrayEquals(float[] d1, float[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); }
FloatArrays { public static boolean arrayEquals(float[] d1, float[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } }
FloatArrays { public static boolean arrayEquals(float[] d1, float[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private FloatArrays(); }
FloatArrays { public static boolean arrayEquals(float[] d1, float[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] ...
FloatArrays { public static boolean arrayEquals(float[] d1, float[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] ...
@Test public void testGeneration3() { WordGenerator wordGenerator = new WordGenerator(getMorphotactics("elma")); List<String> morphemes = Lists.newArrayList("Noun", "With"); List<Result> results = wordGenerator.generate( "elma", morphemes ); Assert.assertTrue(results.size() > 0); Assert.assertEquals("elmalı", results.g...
public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPrefixMatches(stem...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
@Test public void testMultiply() { float[] da = {-1, 1.3f, 8.2f, 10, 90}; float[] da2 = {-1, 3, 2, 2, -1}; Assert.assertTrue(inDelta(FloatArrays.multiply(da, da2), new float[]{1, 3.9f, 16.4f, 20, -90})); FloatArrays.multiplyToFirst(da, da2); Assert.assertTrue(inDelta(da, new float[]{1, 3.9f, 16.4f, 20, -90})); }
public static float[] multiply(float[] a1, float[] a2) { validateArrays(a1, a2); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; }
FloatArrays { public static float[] multiply(float[] a1, float[] a2) { validateArrays(a1, a2); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } }
FloatArrays { public static float[] multiply(float[] a1, float[] a2) { validateArrays(a1, a2); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private FloatArrays(); }
FloatArrays { public static float[] multiply(float[] a1, float[] a2) { validateArrays(a1, a2); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[]...
FloatArrays { public static float[] multiply(float[] a1, float[] a2) { validateArrays(a1, a2); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[]...
@Test public void testScale() { float[] da = {1, -1, 3.1f, 0.0f, 0}; Assert.assertTrue(inDelta(FloatArrays.scale(da, 0), new float[]{0, 0, 0, 0, 0})); Assert.assertTrue(inDelta(FloatArrays.scale(da, -1), new float[]{-1, 1, -3.1f, 0, 0.0f})); Assert.assertTrue(inDelta(FloatArrays.scale(da, 4), new float[]{4, -4, 12.4f, ...
public static float[] scale(float[] a1, float b) { validateArray(a1); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; }
FloatArrays { public static float[] scale(float[] a1, float b) { validateArray(a1); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } }
FloatArrays { public static float[] scale(float[] a1, float b) { validateArray(a1); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private FloatArrays(); }
FloatArrays { public static float[] scale(float[] a1, float b) { validateArray(a1); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static...
FloatArrays { public static float[] scale(float[] a1, float b) { validateArray(a1); float[] mul = new float[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static...
@Test public void testAbsoluteDifference() { float[] da = {1, 2, 4.5f, -2, 4}; float[] da2 = {1, 1, 2.5f, 5, -15.2f}; Assert.assertTrue( inDelta(FloatArrays.absoluteDifference(da, da2), new float[]{0, 1, 2, 7, 19.2f})); Assert.assertEquals(FloatArrays.absoluteSumOfDifferences(da, da2), 29.2f, 0.0001); }
public static float[] absoluteDifference(float[] a, float[] b) { validateArrays(a, b); float[] diff = new float[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; }
FloatArrays { public static float[] absoluteDifference(float[] a, float[] b) { validateArrays(a, b); float[] diff = new float[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } }
FloatArrays { public static float[] absoluteDifference(float[] a, float[] b) { validateArrays(a, b); float[] diff = new float[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private FloatArrays(); }
FloatArrays { public static float[] absoluteDifference(float[] a, float[] b) { validateArrays(a, b); float[] diff = new float[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reve...
FloatArrays { public static float[] absoluteDifference(float[] a, float[] b) { validateArrays(a, b); float[] diff = new float[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reve...
@Test public void testVariance() { float[] da = {0, 2, 4}; Assert.assertEquals(FloatArrays.variance(da), 4f, 0.0001); Assert.assertEquals(FloatArrays.standardDeviation(da), 2f, 0.0001); }
public static float variance(float[] input) { float sigmaSquare = 0; float mean = mean(input); for (float a : input) { float meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); }
FloatArrays { public static float variance(float[] input) { float sigmaSquare = 0; float mean = mean(input); for (float a : input) { float meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } }
FloatArrays { public static float variance(float[] input) { float sigmaSquare = 0; float mean = mean(input); for (float a : input) { float meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private FloatArrays(); }
FloatArrays { public static float variance(float[] input) { float sigmaSquare = 0; float mean = mean(input); for (float a : input) { float meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private FloatArrays(); static boolean inRange(float d1, float d2, float range)...
FloatArrays { public static float variance(float[] input) { float sigmaSquare = 0; float mean = mean(input); for (float a : input) { float meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private FloatArrays(); static boolean inRange(float d1, float d2, float range)...
@Test public void testContainsNaN() { float[] da = {-1, 1, 3, 5, 7, 9, Float.NaN}; Assert.assertTrue(FloatArrays.containsNaN(da)); float[] da2 = {-1, 1, 3, 5, 7, 9}; Assert.assertFalse(FloatArrays.containsNaN(da2)); }
public static boolean containsNaN(float[] a) { for (float v : a) { if (Float.isNaN(v)) { return true; } } return false; }
FloatArrays { public static boolean containsNaN(float[] a) { for (float v : a) { if (Float.isNaN(v)) { return true; } } return false; } }
FloatArrays { public static boolean containsNaN(float[] a) { for (float v : a) { if (Float.isNaN(v)) { return true; } } return false; } private FloatArrays(); }
FloatArrays { public static boolean containsNaN(float[] a) { for (float v : a) { if (Float.isNaN(v)) { return true; } } return false; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(in...
FloatArrays { public static boolean containsNaN(float[] a) { for (float v : a) { if (Float.isNaN(v)) { return true; } } return false; } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(in...
@Test public void testFloorInPlace() { float[] da = {0, -7, 2, 1.1123f, -10, -22, 56}; FloatArrays.floorInPlace(da, -7); Assert.assertTrue(inDelta(da, new float[]{0, -7, 2, 1.1123f, -7, -7, 56})); }
public static void floorInPlace(float[] var, float minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } }
FloatArrays { public static void floorInPlace(float[] var, float minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } }
FloatArrays { public static void floorInPlace(float[] var, float minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private FloatArrays(); }
FloatArrays { public static void floorInPlace(float[] var, float minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input...
FloatArrays { public static void floorInPlace(float[] var, float minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input...
@Test public void testNonZeroFloorInPlace() { float[] da = {0, -7, 2, 1.1123f, -10, -22, 56}; FloatArrays.nonZeroFloorInPlace(da, 3); Assert.assertTrue(inDelta(da, new float[]{0, 3, 3, 3, 3, 3, 56})); }
public static void nonZeroFloorInPlace(float[] data, float floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0f && data[i] < floor) { data[i] = floor; } } }
FloatArrays { public static void nonZeroFloorInPlace(float[] data, float floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0f && data[i] < floor) { data[i] = floor; } } } }
FloatArrays { public static void nonZeroFloorInPlace(float[] data, float floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0f && data[i] < floor) { data[i] = floor; } } } private FloatArrays(); }
FloatArrays { public static void nonZeroFloorInPlace(float[] data, float floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0f && data[i] < floor) { data[i] = floor; } } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[...
FloatArrays { public static void nonZeroFloorInPlace(float[] data, float floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0f && data[i] < floor) { data[i] = floor; } } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[...
@Test public void testNormalizeInPlace() { float[] da = {1, 5.6f, 2.4f, -1, -3.0f, 5}; FloatArrays.normalizeInPlace(da); Assert.assertTrue(inDelta(da, new float[]{0.1f, 0.56f, 0.24f, -0.1f, -0.3f, 0.5f})); }
public static void normalizeInPlace(float[] data) { float sum = sum(data); scaleInPlace(data, 1f / sum); }
FloatArrays { public static void normalizeInPlace(float[] data) { float sum = sum(data); scaleInPlace(data, 1f / sum); } }
FloatArrays { public static void normalizeInPlace(float[] data) { float sum = sum(data); scaleInPlace(data, 1f / sum); } private FloatArrays(); }
FloatArrays { public static void normalizeInPlace(float[] data) { float sum = sum(data); scaleInPlace(data, 1f / sum); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); s...
FloatArrays { public static void normalizeInPlace(float[] data) { float sum = sum(data); scaleInPlace(data, 1f / sum); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); s...
@Test public void testAddToAll() { float[] da = {1, 2, 0, -1, -3}; float[] expected = {2, 3, 1, 0, -2}; FloatArrays.addToAll(da, 1); Assert.assertTrue(Arrays.equals(expected, da)); }
public static void addToAll(float[] data, float valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } }
FloatArrays { public static void addToAll(float[] data, float valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } }
FloatArrays { public static void addToAll(float[] data, float valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private FloatArrays(); }
FloatArrays { public static void addToAll(float[] data, float valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
FloatArrays { public static void addToAll(float[] data, float valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input);...
@Test public void testValidateArray() { float[] da = null; try { FloatArrays.validateArray(da); } catch (IllegalArgumentException e) { Assert.assertTrue(true); } da = new float[0]; try { FloatArrays.validateArray(da); } catch (IllegalArgumentException e) { Assert.assertTrue(true); } }
public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static f...
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static f...
@Test public void testGeneration4() { TurkishMorphotactics mo = getMorphotactics("elma"); WordGenerator wordGenerator = new WordGenerator(mo); List<String> morphemes = Lists.newArrayList("Noun", "A3pl", "P1pl"); List<Result> results = wordGenerator.generate( mo.getRootLexicon().getItemById("elma_Noun"), TurkishMorphota...
public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPrefixMatches(stem...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
@Test public void testValidateArrays() { float[] da1 = {1, 2, 3}; float[] da2 = null; try { FloatArrays.validateArrays(da1, da2); } catch (NullPointerException e) { Assert.assertTrue(true); } float[] da3 = {5, 6, 2.33f, 2}; try { FloatArrays.validateArrays(da1, da3); } catch (IllegalArgumentException e) { Assert.assert...
public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:" +...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
@Test public void testNormalize16bitLittleEndian() { byte[] ba = {0x10, 0x71, 0x18, 0x54}; float[] da = FloatArrays.normalize16bitLittleEndian(ba); Assert.assertEquals(da[0] * Short.MAX_VALUE, 28944f, 0.0001); Assert.assertEquals(da[1] * Short.MAX_VALUE, 21528f, 0.0001); byte[] ba2 = FloatArrays.denormalize16BitLittleE...
public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(i...
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(i...
@Test public void testToUnsignedInteger() { float[] da = {0.2f, -0.4f, 0.6f}; int[] ia = FloatArrays.toUnsignedInteger(da, 6); Assert.assertEquals((int) (0.2f * 3.0f), ia[0]); Assert.assertEquals((int) (-0.4f * 3.0f), ia[1]); }
public static int[] toUnsignedInteger(float[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] arr = new int[input.length]; float divider = (float) ((double) max / 2.0); for (int i = 0; i < input.length; i++) { float d = input[i]; if (d...
FloatArrays { public static int[] toUnsignedInteger(float[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] arr = new int[input.length]; float divider = (float) ((double) max / 2.0); for (int i = 0; i < input.length; i++) { float d = i...
FloatArrays { public static int[] toUnsignedInteger(float[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] arr = new int[input.length]; float divider = (float) ((double) max / 2.0); for (int i = 0; i < input.length; i++) { float d = i...
FloatArrays { public static int[] toUnsignedInteger(float[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] arr = new int[input.length]; float divider = (float) ((double) max / 2.0); for (int i = 0; i < input.length; i++) { float d = i...
FloatArrays { public static int[] toUnsignedInteger(float[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] arr = new int[input.length]; float divider = (float) ((double) max / 2.0); for (int i = 0; i < input.length; i++) { float d = i...
@Test public void testFormat() { float[] da = {0.2f, -0.45f, 0.6f}; Assert.assertEquals("0.2 -0.4 0.6", FloatArrays.format(1, " ", da)); Assert.assertEquals("0.20 -0.45 0.60", FloatArrays.format(2, " ", da)); Assert.assertEquals("0.20, -0.45, 0.60", FloatArrays.format(2, ", ", da)); Assert.assertEquals("0.20-0.450.60",...
public static String format(float... input) { return format(10, 3, " ", input); }
FloatArrays { public static String format(float... input) { return format(10, 3, " ", input); } }
FloatArrays { public static String format(float... input) { return format(10, 3, " ", input); } private FloatArrays(); }
FloatArrays { public static String format(float... input) { return format(10, 3, " ", input); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static float[] convert(dou...
FloatArrays { public static String format(float... input) { return format(10, 3, " ", input); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(int[][] input); static float[] convert(dou...
@Test(expected = IllegalArgumentException.class) public void testValidateArrayExc() { float[] da1 = new float[0]; FloatArrays.validateArray(da1); }
public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); }
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static f...
FloatArrays { public static void validateArray(float... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static f...
@Test(expected = NullPointerException.class) public void testValidateArraysNullExc() { float[] da1 = null; float[] da2 = null; FloatArrays.validateArrays(da1, da2); }
public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:" +...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
@Test(expected = IllegalArgumentException.class) public void testValidateArraysArgExc() { float[] da1 = new float[2]; float[] da2 = new float[3]; FloatArrays.validateArrays(da1, da2); }
public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:" +...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
FloatArrays { public static void validateArrays(float[] a1, float[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. ...
@Test(expected = IllegalArgumentException.class) public void testNormalize16bitExc() { byte[] ba = {-10, 45, 120}; FloatArrays.normalize16bitLittleEndian(ba); }
public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); }
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(i...
FloatArrays { public static float[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private FloatArrays(); static boolean inRange(float d1, float d2, float range); static float[] reverse(float[] input); static float[] convert(int[] input); static float[][] convert(i...
@Test public void testSum() { double[] da = {1, 2, 0, -1, -3}; double[] da2 = {0.5, -2, 30, 1, -30}; Assert.assertTrue(inDelta(DoubleArrays.sum(da), -1)); Assert.assertTrue(inDelta(DoubleArrays.sum(da, da2), new double[]{1.5, 0, 30, 0, -33})); DoubleArrays.addToFirst(da, da2); Assert.assertTrue(inDelta(da, new double[]...
public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private DoubleArrays(); }
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[...
DoubleArrays { public static double sum(double... input) { double sum = 0; for (double v : input) { sum += v; } return sum; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[...
@Test public void addToFirstScaledTest() { double[] da1 = {1, 2, 0, -1, -30}; double[] da2 = {-0.5, -1, 0, 0.5, 15}; DoubleArrays.addToFirstScaled(da1, da2, 2); Assert.assertEquals(DoubleArrays.max(da1), 0d, 0.0001); Assert.assertEquals(DoubleArrays.min(da1), 0d, 0.0001); }
public static void addToFirstScaled(double[] first, double[] second, double scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } }
DoubleArrays { public static void addToFirstScaled(double[] first, double[] second, double scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } }
DoubleArrays { public static void addToFirstScaled(double[] first, double[] second, double scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private DoubleArrays(); }
DoubleArrays { public static void addToFirstScaled(double[] first, double[] second, double scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] re...
DoubleArrays { public static void addToFirstScaled(double[] first, double[] second, double scale) { validateArrays(first, second); for (int i = 0; i < first.length; i++) { first[i] = first[i] + second[i] * scale; } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] re...
@Test public void testGeneration5() { TurkishMorphotactics mo = getMorphotactics("yapmak"); WordGenerator wordGenerator = new WordGenerator(mo); List<String> morphemes = Lists.newArrayList("Verb", "Opt", "A1pl"); DictionaryItem item = mo.getRootLexicon().getItemById("yapmak_Verb"); List<Result> results = wordGenerator....
public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPrefixMatches(stem...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
WordGenerator { public List<Result> generate(String stem, List<String> morphemeIds) { List<Morpheme> morphemes = new ArrayList<>(); for (String morphemeId : morphemeIds) { Morpheme morpheme = TurkishMorphotactics.getMorpheme(morphemeId); morphemes.add(morpheme); } List<StemTransition> candidates = stemTransitions.getPr...
@Test public void testDotProduct() { double[] da = {1, 2, 0, -1, -3}; double[] da2 = {0.5, -2, 30, 1, -30}; Assert.assertTrue(inDelta(DoubleArrays.dotProduct(da, da2), 85.5)); }
public static double dotProduct(double[] a1, double[] a2) { return sum(multiply(a1, a2)); }
DoubleArrays { public static double dotProduct(double[] a1, double[] a2) { return sum(multiply(a1, a2)); } }
DoubleArrays { public static double dotProduct(double[] a1, double[] a2) { return sum(multiply(a1, a2)); } private DoubleArrays(); }
DoubleArrays { public static double dotProduct(double[] a1, double[] a2) { return sum(multiply(a1, a2)); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] input); static ...
DoubleArrays { public static double dotProduct(double[] a1, double[] a2) { return sum(multiply(a1, a2)); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] input); static ...
@Test public void testAppendZeros() { double[] da = {1, 2, 0, -1, -3}; double[] da2 = {1, 2, 0, -1, -3, 0, 0, 0, 0, 0, 0}; Assert.assertTrue(inDelta(DoubleArrays.appendZeros(da, 6), da2)); Assert.assertTrue(inDelta(DoubleArrays.appendZeros(da2, 0), da2)); }
public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); }
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } }
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
@Test(expected = IllegalArgumentException.class) public void testAppendZerosExc() { double[] da = {1, 2, 0, -1, -3}; DoubleArrays.appendZeros(da, -10); }
public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); }
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } }
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
DoubleArrays { public static double[] appendZeros(double[] darray, int zeroAmountToAppend) { if (zeroAmountToAppend < 0) { throw new IllegalArgumentException( "Cannot append negative amount of zeros. Amount:" + zeroAmountToAppend); } return Arrays.copyOf(darray, darray.length + zeroAmountToAppend); } private DoubleArr...
@Test public void testSquare() { double[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(DoubleArrays.square(da), new double[]{1, 4, 0, 1, 9})); }
public static double[] square(double... input) { double[] res = new double[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; }
DoubleArrays { public static double[] square(double... input) { double[] res = new double[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } }
DoubleArrays { public static double[] square(double... input) { double[] res = new double[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private DoubleArrays(); }
DoubleArrays { public static double[] square(double... input) { double[] res = new double[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); st...
DoubleArrays { public static double[] square(double... input) { double[] res = new double[input.length]; for (int i = 0; i < input.length; i++) { res[i] = input[i] * input[i]; } return res; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); st...
@Test public void testSquaredSum() { double[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(DoubleArrays.squaredSum(da), 15)); double[] da2 = {0, 1, 1, -2, 1}; Assert.assertTrue(inDelta(DoubleArrays.squaredSumOfDifferences(da, da2), 20)); Assert .assertTrue(inDelta(DoubleArrays.absoluteDifference(da, da2), new doub...
public static double squaredSum(double[] array) { double result = 0; validateArray(array); for (double a : array) { result += a * a; } return result; }
DoubleArrays { public static double squaredSum(double[] array) { double result = 0; validateArray(array); for (double a : array) { result += a * a; } return result; } }
DoubleArrays { public static double squaredSum(double[] array) { double result = 0; validateArray(array); for (double a : array) { result += a * a; } return result; } private DoubleArrays(); }
DoubleArrays { public static double squaredSum(double[] array) { double result = 0; validateArray(array); for (double a : array) { result += a * a; } return result; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int...
DoubleArrays { public static double squaredSum(double[] array) { double result = 0; validateArray(array); for (double a : array) { result += a * a; } return result; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int...
@Test public void testAddToAll() { double[] da = {1, 2, 0, -1, -3}; double[] expected = {2, 3, 1, 0, -2}; DoubleArrays.addToAll(da, 1); Assert.assertTrue(Arrays.equals(expected, da)); }
public static void addToAll(double[] data, double valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } }
DoubleArrays { public static void addToAll(double[] data, double valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } }
DoubleArrays { public static void addToAll(double[] data, double valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private DoubleArrays(); }
DoubleArrays { public static void addToAll(double[] data, double valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int...
DoubleArrays { public static void addToAll(double[] data, double valueToAdd) { validateArray(data); for (int i = 0; i < data.length; i++) { data[i] += valueToAdd; } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int...
@Test public void testMean() { double[] da = {1, 2, 0, -1, -3}; Assert.assertTrue(inDelta(DoubleArrays.mean(da), -1d / 5d)); }
public static double mean(double... input) { validateArray(input); return sum(input) / input.length; }
DoubleArrays { public static double mean(double... input) { validateArray(input); return sum(input) / input.length; } }
DoubleArrays { public static double mean(double... input) { validateArray(input); return sum(input) / input.length; } private DoubleArrays(); }
DoubleArrays { public static double mean(double... input) { validateArray(input); return sum(input) / input.length; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] inpu...
DoubleArrays { public static double mean(double... input) { validateArray(input); return sum(input) / input.length; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] inpu...
@Test public void testInRange() { double d = 3; double d2 = 2.5; double d3 = 7; Assert.assertTrue(DoubleArrays.inRange(d, d2, 1)); Assert.assertFalse(DoubleArrays.inRange(d2, d3, 4)); Assert.assertTrue(DoubleArrays.inRange(d, d2, 0.5)); }
public static boolean inRange(double d1, double d2, double range) { return Math.abs(d1 - d2) <= range; }
DoubleArrays { public static boolean inRange(double d1, double d2, double range) { return Math.abs(d1 - d2) <= range; } }
DoubleArrays { public static boolean inRange(double d1, double d2, double range) { return Math.abs(d1 - d2) <= range; } private DoubleArrays(); }
DoubleArrays { public static boolean inRange(double d1, double d2, double range) { return Math.abs(d1 - d2) <= range; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] in...
DoubleArrays { public static boolean inRange(double d1, double d2, double range) { return Math.abs(d1 - d2) <= range; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][] in...
@Test public void testReverse() { double[] da = {1, 3, 7, 2.5, 0}; double[] da2 = DoubleArrays.reverse(DoubleArrays.reverse(da)); Assert.assertNotNull(da2); Assert.assertEquals(da.length, da2.length); Assert.assertTrue(inDelta(da, da2)); }
public static double[] reverse(double[] input) { double[] result = new double[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; }
DoubleArrays { public static double[] reverse(double[] input) { double[] result = new double[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } }
DoubleArrays { public static double[] reverse(double[] input) { double[] result = new double[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private DoubleArrays(); }
DoubleArrays { public static double[] reverse(double[] input) { double[] result = new double[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(do...
DoubleArrays { public static double[] reverse(double[] input) { double[] result = new double[input.length]; for (int i = 0; i < input.length; i++) { result[input.length - i - 1] = input[i]; } return result; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(do...
@Test public void testConvertInt() { int[] ia = {1, 3, -1, 0, 9, 12}; double[] da2 = {1, 3, -1, 0, 9.0, 12.0}; double[] da = DoubleArrays.convert(ia); Assert.assertNotNull(da); Assert.assertTrue(inDelta(da, da2)); }
public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
@Test public void loadNounsFromFileTest() throws IOException { RootLexicon items = TurkishDictionaryLoader .load(new File(Resources.getResource("test-lexicon-nouns.txt").getFile())); Assert.assertFalse(items.isEmpty()); for (DictionaryItem item : items) { Assert.assertSame(item.primaryPos, Noun); } }
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test public void testConvert2d() { int[][] ia = {{1, 2}, {4, 3}, {-1, 5}}; double[][] da = {{1, 2}, {4, 3}, {-1, 5}}; double[][] da2 = DoubleArrays.convert(ia); Assert.assertEquals(ia.length, da2.length); Assert.assertNotNull(da2); int k = 0; for (double[] i : da) { int j = 0; for (double ii : i) { Assert.assertEquals...
public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
@Test public void testConvertFloat() { float[] fa = {1, 3, -1, 0, 9, 12}; double[] da2 = {1, 3, -1, 0, 9.0, 12.0}; double[] da = DoubleArrays.convert(fa); Assert.assertNotNull(da); Assert.assertTrue(inDelta(da, da2)); }
public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); }
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
DoubleArrays { public static double[] convert(int[] input) { double[] data = new double[input.length]; int k = 0; for (int i : input) { data[k++] = i; } return data; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(in...
@Test public void testArrayEqualsInRange() { double[] da = {0, 3.5, 7, -2, 19}; double[] da2 = {0, 4.5, 4, 2, -18}; Assert.assertTrue(DoubleArrays.arrayEqualsInRange(da, da2, 37)); Assert.assertFalse(DoubleArrays.arrayEqualsInRange(da, da2, 15)); Assert.assertTrue(DoubleArrays.arrayEqualsInRange(da, da2, 45)); }
public static boolean arrayEqualsInRange(double[] d1, double[] d2, double range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; }
DoubleArrays { public static boolean arrayEqualsInRange(double[] d1, double[] d2, double range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } }
DoubleArrays { public static boolean arrayEqualsInRange(double[] d1, double[] d2, double range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private DoubleArrays(); }
DoubleArrays { public static boolean arrayEqualsInRange(double[] d1, double[] d2, double range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); sta...
DoubleArrays { public static boolean arrayEqualsInRange(double[] d1, double[] d2, double range) { validateArrays(d1, d2); for (int i = 0; i < d1.length; i++) { if (Math.abs(d1[i] - d2[i]) > range) { return false; } } return true; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); sta...
@Test public void testArrayEquals() { double[] da = {-1, 0, 3.4, 7}; double[] da2 = {-1, 0.0, 3.4, 7}; double[] da3 = {7, 9.0, 12.3, -5.6}; Assert.assertTrue(DoubleArrays.arrayEquals(da, da2)); Assert.assertFalse(DoubleArrays.arrayEquals(da2, da3)); }
public static boolean arrayEquals(double[] d1, double[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); }
DoubleArrays { public static boolean arrayEquals(double[] d1, double[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } }
DoubleArrays { public static boolean arrayEquals(double[] d1, double[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private DoubleArrays(); }
DoubleArrays { public static boolean arrayEquals(double[] d1, double[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] conve...
DoubleArrays { public static boolean arrayEquals(double[] d1, double[] d2) { validateArrays(d1, d2); return Arrays.equals(d1, d2); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] conve...
@Test public void testMultiply() { double[] da = {-1, 1.3, 8.2, 10, 90}; double[] da2 = {-1, 3, 2, 2, -1}; Assert.assertTrue(inDelta(DoubleArrays.multiply(da, da2), new double[]{1, 3.9, 16.4, 20, -90})); DoubleArrays.multiplyToFirst(da, da2); Assert.assertTrue(inDelta(da, new double[]{1, 3.9, 16.4, 20, -90})); }
public static double[] multiply(double[] a1, double[] a2) { validateArrays(a1, a2); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; }
DoubleArrays { public static double[] multiply(double[] a1, double[] a2) { validateArrays(a1, a2); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } }
DoubleArrays { public static double[] multiply(double[] a1, double[] a2) { validateArrays(a1, a2); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private DoubleArrays(); }
DoubleArrays { public static double[] multiply(double[] a1, double[] a2) { validateArrays(a1, a2); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reve...
DoubleArrays { public static double[] multiply(double[] a1, double[] a2) { validateArrays(a1, a2); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * a2[i]; } return mul; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reve...
@Test public void testScale() { double[] da = {1, -1, 3.1, 0.0, 0}; Assert.assertTrue(inDelta(DoubleArrays.scale(da, 0), new double[]{0, 0, 0, 0, 0})); Assert.assertTrue(inDelta(DoubleArrays.scale(da, -1), new double[]{-1, 1, -3.1, 0, 0.0})); Assert.assertTrue(inDelta(DoubleArrays.scale(da, 4), new double[]{4, -4, 12.4...
public static double[] scale(double[] a1, double b) { validateArray(a1); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; }
DoubleArrays { public static double[] scale(double[] a1, double b) { validateArray(a1); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } }
DoubleArrays { public static double[] scale(double[] a1, double b) { validateArray(a1); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private DoubleArrays(); }
DoubleArrays { public static double[] scale(double[] a1, double b) { validateArray(a1); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] in...
DoubleArrays { public static double[] scale(double[] a1, double b) { validateArray(a1); double[] mul = new double[a1.length]; for (int i = 0; i < a1.length; i++) { mul[i] = a1[i] * b; } return mul; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] in...
@Test public void testAbsoluteDifference() { double[] da = {1, 2, 4.5, -2, 4}; double[] da2 = {1, 1, 2.5, 5, -15.2}; Assert.assertTrue( inDelta(DoubleArrays.absoluteDifference(da, da2), new double[]{0, 1, 2, 7, 19.2})); Assert.assertEquals(DoubleArrays.absoluteSumOfDifferences(da, da2), 29.2, 0.0001); }
public static double[] absoluteDifference(double[] a, double[] b) { validateArrays(a, b); double[] diff = new double[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; }
DoubleArrays { public static double[] absoluteDifference(double[] a, double[] b) { validateArrays(a, b); double[] diff = new double[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } }
DoubleArrays { public static double[] absoluteDifference(double[] a, double[] b) { validateArrays(a, b); double[] diff = new double[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private DoubleArrays(); }
DoubleArrays { public static double[] absoluteDifference(double[] a, double[] b) { validateArrays(a, b); double[] diff = new double[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static do...
DoubleArrays { public static double[] absoluteDifference(double[] a, double[] b) { validateArrays(a, b); double[] diff = new double[a.length]; for (int i = 0; i < a.length; i++) { diff[i] += abs(a[i] - b[i]); } return diff; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static do...
@Test public void testVariance() { double[] da = {0, 2, 4}; Assert.assertEquals(DoubleArrays.variance(da), 4d, 0.0001); Assert.assertEquals(DoubleArrays.standardDeviation(da), 2d, 0.0001); }
public static double variance(double[] input) { double sigmaSquare = 0; double mean = mean(input); for (double a : input) { final double meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); }
DoubleArrays { public static double variance(double[] input) { double sigmaSquare = 0; double mean = mean(input); for (double a : input) { final double meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } }
DoubleArrays { public static double variance(double[] input) { double sigmaSquare = 0; double mean = mean(input); for (double a : input) { final double meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private DoubleArrays(); }
DoubleArrays { public static double variance(double[] input) { double sigmaSquare = 0; double mean = mean(input); for (double a : input) { final double meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private DoubleArrays(); static boolean inRange(double d1, double ...
DoubleArrays { public static double variance(double[] input) { double sigmaSquare = 0; double mean = mean(input); for (double a : input) { final double meanDiff = a - mean; sigmaSquare += meanDiff * meanDiff; } return sigmaSquare / (input.length - 1); } private DoubleArrays(); static boolean inRange(double d1, double ...
@Test public void testContainsNaN() { double[] da = {-1, 1, 3, 5, 7, 9, Double.NaN}; Assert.assertTrue(DoubleArrays.containsNaN(da)); double[] da2 = {-1, 1, 3, 5, 7, 9}; Assert.assertFalse(DoubleArrays.containsNaN(da2)); }
public static boolean containsNaN(double[] a) { for (double v : a) { if (Double.isNaN(v)) { return true; } } return false; }
DoubleArrays { public static boolean containsNaN(double[] a) { for (double v : a) { if (Double.isNaN(v)) { return true; } } return false; } }
DoubleArrays { public static boolean containsNaN(double[] a) { for (double v : a) { if (Double.isNaN(v)) { return true; } } return false; } private DoubleArrays(); }
DoubleArrays { public static boolean containsNaN(double[] a) { for (double v : a) { if (Double.isNaN(v)) { return true; } } return false; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][...
DoubleArrays { public static boolean containsNaN(double[] a) { for (double v : a) { if (Double.isNaN(v)) { return true; } } return false; } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][...
@Test public void testFloorInPlace() { double[] da = {0, -7, 2, 1.1123, -10, -22, 56}; DoubleArrays.floorInPlace(da, -7); Assert.assertTrue(inDelta(da, new double[]{0, -7, 2, 1.1123, -7, -7, 56})); }
public static void floorInPlace(double[] var, double minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } }
DoubleArrays { public static void floorInPlace(double[] var, double minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } }
DoubleArrays { public static void floorInPlace(double[] var, double minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private DoubleArrays(); }
DoubleArrays { public static void floorInPlace(double[] var, double minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(i...
DoubleArrays { public static void floorInPlace(double[] var, double minValue) { for (int k = 0; k < var.length; k++) { if (var[k] < minValue) { var[k] = minValue; } } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(i...
@Test public void voicingInferenceTest() { DictionaryItem item = TurkishDictionaryLoader.loadFromString("aort [A:NoVoicing]"); Assert.assertEquals("aort", item.root); Assert.assertEquals(Noun, item.primaryPos); Assert.assertTrue(item.hasAttribute(RootAttribute.NoVoicing)); Assert.assertFalse(item.hasAttribute(RootAttri...
public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
@Test public void testNonZeroFloorInPlace() { double[] da = {0, -7, 2, 1.1123, -10, -22, 56}; DoubleArrays.nonZeroFloorInPlace(da, 3); Assert.assertTrue(inDelta(da, new double[]{0, 3, 3, 3, 3, 3, 56})); }
public static void nonZeroFloorInPlace(double[] data, double floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0 && data[i] < floor) { data[i] = floor; } } }
DoubleArrays { public static void nonZeroFloorInPlace(double[] data, double floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0 && data[i] < floor) { data[i] = floor; } } } }
DoubleArrays { public static void nonZeroFloorInPlace(double[] data, double floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0 && data[i] < floor) { data[i] = floor; } } } private DoubleArrays(); }
DoubleArrays { public static void nonZeroFloorInPlace(double[] data, double floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0 && data[i] < floor) { data[i] = floor; } } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); stati...
DoubleArrays { public static void nonZeroFloorInPlace(double[] data, double floor) { for (int i = 0; i < data.length; i++) { if (data[i] != 0.0 && data[i] < floor) { data[i] = floor; } } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); stati...
@Test public void testNormalizeInPlace() { double[] da = {1, 5.6, 2.4, -1, -3.0, 5}; DoubleArrays.normalizeInPlace(da); Assert.assertTrue(inDelta(da, new double[]{0.1, 0.56, 0.24, -0.1, -0.3, 0.5})); }
public static void normalizeInPlace(double[] data) { double sum = sum(data); scaleInPlace(data, 1d / sum); }
DoubleArrays { public static void normalizeInPlace(double[] data) { double sum = sum(data); scaleInPlace(data, 1d / sum); } }
DoubleArrays { public static void normalizeInPlace(double[] data) { double sum = sum(data); scaleInPlace(data, 1d / sum); } private DoubleArrays(); }
DoubleArrays { public static void normalizeInPlace(double[] data) { double sum = sum(data); scaleInPlace(data, 1d / sum); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][...
DoubleArrays { public static void normalizeInPlace(double[] data) { double sum = sum(data); scaleInPlace(data, 1d / sum); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][] convert(int[][...
@Test public void testValidateArray() { double[] da = null; try { DoubleArrays.validateArray(da); } catch (IllegalArgumentException e) { Assert.assertTrue(true); } da = new double[0]; try { DoubleArrays.validateArray(da); } catch (IllegalArgumentException e) { Assert.assertTrue(true); } }
public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); st...
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); st...
@Test public void testValidateArrays() { double[] da1 = {1, 2, 3}; double[] da2 = null; try { DoubleArrays.validateArrays(da1, da2); } catch (NullPointerException e) { Assert.assertTrue(true); } double[] da3 = {5, 6, 2.33, 2}; try { DoubleArrays.validateArrays(da1, da3); } catch (IllegalArgumentException e) { Assert.as...
public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:"...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
@Test public void testNormalize16bitLittleEndian() { byte[] ba = {0x10, 0x71, 0x18, 0x54}; double[] da = DoubleArrays.normalize16bitLittleEndian(ba); Assert.assertEquals(da[0] * Short.MAX_VALUE, 28944d, 0.0001); Assert.assertEquals(da[1] * Short.MAX_VALUE, 21528d, 0.0001); byte[] ba2 = DoubleArrays.denormalize16BitLitt...
public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][]...
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][]...
@Test public void testToUnsignedInteger() { double[] da = {0.2, -0.4, 0.6}; int[] ia = DoubleArrays.toUnsignedInteger(da, 6); Assert.assertEquals((int) (0.2 * 3.0), ia[0]); Assert.assertEquals((int) (-0.4 * 3.0), ia[1]); }
public static int[] toUnsignedInteger(double[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] iarr = new int[input.length]; double divider = (double) max / 2.0; for (int i = 0; i < input.length; i++) { double d = input[i]; if (d < -1....
DoubleArrays { public static int[] toUnsignedInteger(double[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] iarr = new int[input.length]; double divider = (double) max / 2.0; for (int i = 0; i < input.length; i++) { double d = input[...
DoubleArrays { public static int[] toUnsignedInteger(double[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] iarr = new int[input.length]; double divider = (double) max / 2.0; for (int i = 0; i < input.length; i++) { double d = input[...
DoubleArrays { public static int[] toUnsignedInteger(double[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] iarr = new int[input.length]; double divider = (double) max / 2.0; for (int i = 0; i < input.length; i++) { double d = input[...
DoubleArrays { public static int[] toUnsignedInteger(double[] input, int max) { if (max < 1) { throw new IllegalArgumentException("Maximum int value must be positive. But it is:" + max); } int[] iarr = new int[input.length]; double divider = (double) max / 2.0; for (int i = 0; i < input.length; i++) { double d = input[...
@Test(expected = IllegalArgumentException.class) public void testValidateArrayExc() { double[] da1 = new double[0]; DoubleArrays.validateArray(da1); }
public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); }
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); st...
DoubleArrays { public static void validateArray(double... input) { if (input == null) { throw new IllegalArgumentException("array is null!"); } else if (input.length == 0) { throw new IllegalArgumentException("array is empty!"); } } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); st...
@Test(expected = NullPointerException.class) public void testValidateArraysNullExc() { double[] da1 = null; double[] da2 = null; DoubleArrays.validateArrays(da1, da2); }
public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:"...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
@Test(expected = IllegalArgumentException.class) public void testValidateArraysArgExc() { double[] da1 = new double[2]; double[] da2 = new double[3]; DoubleArrays.validateArrays(da1, da2); }
public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equal. But, first:"...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
DoubleArrays { public static void validateArrays(double[] a1, double[] a2) { if (a1 == null) { throw new NullPointerException("first array is null!"); } if (a2 == null) { throw new NullPointerException("second array is null!"); } if (a1.length != a2.length) { throw new IllegalArgumentException("Array sizes must be equa...
@Test(expected = IllegalArgumentException.class) public void testNormalize16bitExc() { byte[] ba = {-10, 45, 120}; DoubleArrays.normalize16bitLittleEndian(ba); }
public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); }
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][]...
DoubleArrays { public static double[] normalize16bitLittleEndian(byte[] bytez) { return normalize16bitLittleEndian(bytez, bytez.length); } private DoubleArrays(); static boolean inRange(double d1, double d2, double range); static double[] reverse(double[] input); static double[] convert(int[] input); static double[][]...
@Test public void punctuationTest() { DictionaryItem item = TurkishDictionaryLoader.loadFromString("… [P:Punc]"); Assert.assertEquals("…", item.root); Assert.assertEquals(Punctuation, item.primaryPos); }
public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
@Test public void loadTest1() throws IOException { List<String> lines = new ArrayList<>(); for (int i = 0; i < 10000; i++) { lines.add(String.valueOf(i)); } Path path = TestUtil.tempFileWithData(lines); BlockTextLoader loader = BlockTextLoader.fromPath(path, 1000); int i = 0; List<String> read = new ArrayList<>(); for ...
public static BlockTextLoader fromPath(Path corpus, int blockSize) { return new BlockTextLoader(Collections.singletonList(corpus), blockSize); }
BlockTextLoader implements Iterable<TextChunk> { public static BlockTextLoader fromPath(Path corpus, int blockSize) { return new BlockTextLoader(Collections.singletonList(corpus), blockSize); } }
BlockTextLoader implements Iterable<TextChunk> { public static BlockTextLoader fromPath(Path corpus, int blockSize) { return new BlockTextLoader(Collections.singletonList(corpus), blockSize); } BlockTextLoader(List<Path> corpusPaths, int blockSize); }
BlockTextLoader implements Iterable<TextChunk> { public static BlockTextLoader fromPath(Path corpus, int blockSize) { return new BlockTextLoader(Collections.singletonList(corpus), blockSize); } BlockTextLoader(List<Path> corpusPaths, int blockSize); List<Path> getCorpusPaths(); int getBlockSize(); int pathCount(); stat...
BlockTextLoader implements Iterable<TextChunk> { public static BlockTextLoader fromPath(Path corpus, int blockSize) { return new BlockTextLoader(Collections.singletonList(corpus), blockSize); } BlockTextLoader(List<Path> corpusPaths, int blockSize); List<Path> getCorpusPaths(); int getBlockSize(); int pathCount(); stat...
@Test public void testRemove() { Histogram<String> histogram = new Histogram<>(); histogram.add("Apple", "Pear", "Plum", "Apple", "Apple", "Grape", "Pear"); histogram.remove("Apple"); Assert.assertEquals(0, histogram.getCount("Apple")); Assert.assertEquals(2, histogram.getCount("Pear")); Assert.assertEquals(1, histogra...
public void remove(T t) { map.remove(t); }
Histogram implements Iterable<T> { public void remove(T t) { map.remove(t); } }
Histogram implements Iterable<T> { public void remove(T t) { map.remove(t); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); }
Histogram implements Iterable<T> { public void remove(T t) { map.remove(t); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); static Histogram<String> loadFromLines(List<String> lines, char delimiter); static Histogram<String> loadFromLines( List<String> lines, char delimiter...
Histogram implements Iterable<T> { public void remove(T t) { map.remove(t); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); static Histogram<String> loadFromLines(List<String> lines, char delimiter); static Histogram<String> loadFromLines( List<String> lines, char delimiter...
@Test @Ignore("Not a test.") public void testMergePerformance() throws IOException { Histogram<String> first = new Histogram<>(); Histogram<String> second = new Histogram<>(); Set<String> c1 = uniqueStrings(1000000, 5); Set<String> c2 = uniqueStrings(1000000, 5); Stopwatch sw = Stopwatch.createStarted(); first.add(c1);...
public int add(T t) { return add(t, 1); }
Histogram implements Iterable<T> { public int add(T t) { return add(t, 1); } }
Histogram implements Iterable<T> { public int add(T t) { return add(t, 1); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); }
Histogram implements Iterable<T> { public int add(T t) { return add(t, 1); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); static Histogram<String> loadFromLines(List<String> lines, char delimiter); static Histogram<String> loadFromLines( List<String> lines, char delimiter,...
Histogram implements Iterable<T> { public int add(T t) { return add(t, 1); } Histogram(int initialSize); Histogram(Map<T, Integer> countMap); Histogram(); static Histogram<String> loadFromLines(List<String> lines, char delimiter); static Histogram<String> loadFromLines( List<String> lines, char delimiter,...
@Test public void stressTest() { List<String> stringSet = randomNumberStrings(100_000); UIntValueMap<String> a = new UIntValueMap<>(); UIntValueMap<String> b = new UIntValueMap<>(); for (int i = 0; i < 20; i++) { for (String s : stringSet) { char c = s.charAt(s.length() - 1); if (a.contains(s)) { a.incrementByAmount(s,...
public int incrementByAmount(T key, int amount) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int l = locate(key); if (l < 0) { l = -l - 1; values[l] = amount; keys[l] = key; keyCount++; if (values[l] < 0) { throw new IllegalStat...
UIntValueMap extends HashBase<T> implements Iterable<T> { public int incrementByAmount(T key, int amount) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int l = locate(key); if (l < 0) { l = -l - 1; values[l] = amount; keys[l] = k...
UIntValueMap extends HashBase<T> implements Iterable<T> { public int incrementByAmount(T key, int amount) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int l = locate(key); if (l < 0) { l = -l - 1; values[l] = amount; keys[l] = k...
UIntValueMap extends HashBase<T> implements Iterable<T> { public int incrementByAmount(T key, int amount) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int l = locate(key); if (l < 0) { l = -l - 1; values[l] = amount; keys[l] = k...
UIntValueMap extends HashBase<T> implements Iterable<T> { public int incrementByAmount(T key, int amount) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int l = locate(key); if (l < 0) { l = -l - 1; values[l] = amount; keys[l] = k...
@Test public void testAdd() { IntVector darray = new IntVector(); for (int i = 0; i < 10000; i++) { darray.add(i); } Assert.assertEquals(10000, darray.size()); for (int i = 0; i < 10000; i++) { Assert.assertEquals(i, darray.get(i)); } }
public void add(int i) { if (size == data.length) { expand(); } data[size] = i; size++; }
IntVector { public void add(int i) { if (size == data.length) { expand(); } data[size] = i; size++; } }
IntVector { public void add(int i) { if (size == data.length) { expand(); } data[size] = i; size++; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); }
IntVector { public void add(int i) { if (size == data.length) { expand(); } data[size] = i; size++; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); int get(int index); void set(int index, int value); void safeSet(int index, i...
IntVector { public void add(int i) { if (size == data.length) { expand(); } data[size] = i; size++; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); int get(int index); void set(int index, int value); void safeSet(int index, i...
@Test public void testAddAll() { int[] d1 = {2, 4, 5, 17, -1, -2, 5, -123}; IntVector darray = new IntVector(); IntVector i = new IntVector(d1); darray.addAll(i); Assert.assertEquals(i, darray); }
public void addAll(int[] arr) { if (size + arr.length >= data.length) { expand(arr.length); } System.arraycopy(arr, 0, data, size, arr.length); size += arr.length; }
IntVector { public void addAll(int[] arr) { if (size + arr.length >= data.length) { expand(arr.length); } System.arraycopy(arr, 0, data, size, arr.length); size += arr.length; } }
IntVector { public void addAll(int[] arr) { if (size + arr.length >= data.length) { expand(arr.length); } System.arraycopy(arr, 0, data, size, arr.length); size += arr.length; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); }
IntVector { public void addAll(int[] arr) { if (size + arr.length >= data.length) { expand(arr.length); } System.arraycopy(arr, 0, data, size, arr.length); size += arr.length; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); i...
IntVector { public void addAll(int[] arr) { if (size + arr.length >= data.length) { expand(arr.length); } System.arraycopy(arr, 0, data, size, arr.length); size += arr.length; } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); i...
@Test public void testTrimToSize() { IntVector darray = new IntVector(); for (int i = 0; i < 10000; i++) { darray.add(i); } Assert.assertEquals(10000, darray.size()); Assert.assertNotEquals(darray.size(), darray.capacity()); darray.trimToSize(); Assert.assertEquals(10000, darray.size()); Assert.assertEquals(10000, darr...
public void trimToSize() { data = Arrays.copyOf(data, size); }
IntVector { public void trimToSize() { data = Arrays.copyOf(data, size); } }
IntVector { public void trimToSize() { data = Arrays.copyOf(data, size); } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); }
IntVector { public void trimToSize() { data = Arrays.copyOf(data, size); } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); int get(int index); void set(int index, int value); void safeSet(int index, int value); int size(); int ...
IntVector { public void trimToSize() { data = Arrays.copyOf(data, size); } IntVector(); IntVector(int initialCapacity); IntVector(int[] values); void add(int i); void addAll(int[] arr); void addAll(IntVector vec); int get(int index); void set(int index, int value); void safeSet(int index, int value); int size(); int ...
@Test public void fillTest() { LongBitVector vector = new LongBitVector(128); vector.add(128, false); for (int i = 0; i < 128; i++) { Assert.assertTrue(!vector.get(i)); } vector.fill(true); for (int i = 0; i < 128; i++) { Assert.assertTrue(vector.get(i)); } vector.fill(false); for (int i = 0; i < 128; i++) { Assert.ass...
public void fill(boolean bitValue) { if (bitValue) { Arrays.fill(words, 0xffffffffffffffffL); int last = (int) (size / 64); words[last] &= cutMasks[(int) (size & mod64Mask)] >>> 1; } else { Arrays.fill(words, 0); } }
LongBitVector { public void fill(boolean bitValue) { if (bitValue) { Arrays.fill(words, 0xffffffffffffffffL); int last = (int) (size / 64); words[last] &= cutMasks[(int) (size & mod64Mask)] >>> 1; } else { Arrays.fill(words, 0); } } }
LongBitVector { public void fill(boolean bitValue) { if (bitValue) { Arrays.fill(words, 0xffffffffffffffffL); int last = (int) (size / 64); words[last] &= cutMasks[(int) (size & mod64Mask)] >>> 1; } else { Arrays.fill(words, 0); } } LongBitVector(); LongBitVector(long initialCapcity); LongBitVector(long[] words, long...
LongBitVector { public void fill(boolean bitValue) { if (bitValue) { Arrays.fill(words, 0xffffffffffffffffL); int last = (int) (size / 64); words[last] &= cutMasks[(int) (size & mod64Mask)] >>> 1; } else { Arrays.fill(words, 0); } } LongBitVector(); LongBitVector(long initialCapcity); LongBitVector(long[] words, long...
LongBitVector { public void fill(boolean bitValue) { if (bitValue) { Arrays.fill(words, 0xffffffffffffffffL); int last = (int) (size / 64); words[last] &= cutMasks[(int) (size & mod64Mask)] >>> 1; } else { Arrays.fill(words, 0); } } LongBitVector(); LongBitVector(long initialCapcity); LongBitVector(long[] words, long...
@Test public void getTest() { UIntMap<String> map = new UIntMap<>(1); map.put(1, "2"); Assert.assertEquals("2", map.get(1)); Assert.assertNull(map.get(2)); map.put(1, "3"); Assert.assertEquals("3", map.get(1)); map = new UIntMap<>(); for (int i = 0; i < 100000; i++) { map.put(i, String.valueOf(i + 1)); } for (int i = 0...
public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot ...
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo;...
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo;...
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo;...
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo;...
@Test public void getValuesTest() { UIntMap<String> map = new UIntMap<>(); int size = 1000; List<String> expected = new ArrayList<>(); for (int i = 0; i < size; i++) { String value = String.valueOf(i + 1); map.put(i, value); expected.add(value); } Assert.assertEquals(expected, map.getValuesSortedByKey()); }
public List<T> getValues() { List<T> result = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { int key = keys[i]; if (key >= 0) { result.add(values[i]); } } return result; }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public List<T> getValues() { List<T> result = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { int key = keys[i]; if (key >= 0) { result.add(values[i]); } } return result; } }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public List<T> getValues() { List<T> result = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { int key = keys[i]; if (key >= 0) { result.add(values[i]); } } return result; } UIntMap(); UIntMap(int size); }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public List<T> getValues() { List<T> result = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { int key = keys[i]; if (key >= 0) { result.add(values[i]); } } return result; } UIntMap(); UIntMap(int size); T get(int key); boolean containsKey(int key); vo...
UIntMap extends UIntKeyHashBase implements Iterable<T> { public List<T> getValues() { List<T> result = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { int key = keys[i]; if (key >= 0) { result.add(values[i]); } } return result; } UIntMap(); UIntMap(int size); T get(int key); boolean containsKey(int key); vo...
@Test public void properNounsShouldNotHaveVoicingAutomaticallyTest() { DictionaryItem item = TurkishDictionaryLoader.loadFromString("Tokat"); Assert.assertEquals("tokat", item.root); Assert.assertEquals(Noun, item.primaryPos); Assert.assertEquals(SecondaryPos.ProperNoun, item.secondaryPos); Assert.assertFalse(item.hasA...
public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
@Test public void removeSpansWorksCorrectly2() { IntIntMap im = createMap(); int limit = 9999; insertSpan(im, 0, limit); int[] r = TestUtils.createRandomUintArray(1000, limit); for (int i : r) { im.remove(i); } for (int i : r) { assertEquals(im.get(i), IntIntMap.NO_RESULT); } insertSpan(im, 0, limit); checkSpan(im, 0, ...
public int get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return (int) (entry >>> 32); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } }
IntIntMap extends CompactIntMapBase { public int get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return (int) (entry >>> 32); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } } }
IntIntMap extends CompactIntMapBase { public int get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return (int) (entry >>> 32); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } } IntIntMap()...
IntIntMap extends CompactIntMapBase { public int get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return (int) (entry >>> 32); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } } IntIntMap()...
IntIntMap extends CompactIntMapBase { public int get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return (int) (entry >>> 32); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } } IntIntMap()...
@Test public void removeTest2() { IntIntMap map = createMap(); for (int i = 0; i < 10000; i++) { map.put(i, i + 1); } for (int i = 0; i < 10000; i += 3) { map.remove(i); } for (int i = 0; i < 10000; i += 3) { Assert.assertTrue(!map.containsKey(i)); } for (int i = 0; i < 10000; i++) { map.put(i, i + 1); } for (int i = 0...
public void put(int key, int value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } }
IntIntMap extends CompactIntMapBase { public void put(int key, int value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } }
IntIntMap extends CompactIntMapBase { public void put(int key, int value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntIntMap(); IntIntMap(int capacity); }
IntIntMap extends CompactIntMapBase { public void put(int key, int value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntIntMap(); IntIntMap(int capacity); void put(int key, int value); void increment(int...
IntIntMap extends CompactIntMapBase { public void put(int key, int value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntIntMap(); IntIntMap(int capacity); void put(int key, int value); void increment(int...
@Test public void constructorTest2() { IntValueMap<String> set = new IntValueMap<>(1); set.addOrIncrement("foo"); Assert.assertEquals(1, set.size()); set.remove("foo"); Assert.assertEquals(0, set.size()); Assert.assertFalse(set.contains("foo")); }
public int addOrIncrement(T key) { return incrementByAmount(key, 1); }
IntValueMap extends HashBase<T> implements Iterable<T> { public int addOrIncrement(T key) { return incrementByAmount(key, 1); } }
IntValueMap extends HashBase<T> implements Iterable<T> { public int addOrIncrement(T key) { return incrementByAmount(key, 1); } IntValueMap(); IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { public int addOrIncrement(T key) { return incrementByAmount(key, 1); } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmount(T key, int amount); void...
IntValueMap extends HashBase<T> implements Iterable<T> { public int addOrIncrement(T key) { return incrementByAmount(key, 1); } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmount(T key, int amount); void...
@Test public void putTest() { IntValueMap<String> table = new IntValueMap<>(); table.put("foo", 1); Assert.assertEquals(1, table.size()); table.put("foo", 2); Assert.assertEquals(1, table.size()); table = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { table.put(String.valueOf(i), i + 1); Assert.assertEquals(i + ...
public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } }
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[lo...
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[lo...
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[lo...
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[lo...
@Test public void expandTest() { IntValueMap<String> table = new IntValueMap<>(); for (int i = 0; i < 10000; i++) { table.put(String.valueOf(i), i + 1); Assert.assertEquals(i + 1, table.size()); } for (int i = 0; i < 5000; i++) { table.remove(String.valueOf(i)); Assert.assertEquals(10000 - i - 1, table.size()); } for (...
private void expand() { IntValueMap<T> h = new IntValueMap<>(newSize()); for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { h.put(keys[i], values[i]); } } expandCopyParameters(h); this.values = h.values; }
IntValueMap extends HashBase<T> implements Iterable<T> { private void expand() { IntValueMap<T> h = new IntValueMap<>(newSize()); for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { h.put(keys[i], values[i]); } } expandCopyParameters(h); this.values = h.values; } }
IntValueMap extends HashBase<T> implements Iterable<T> { private void expand() { IntValueMap<T> h = new IntValueMap<>(newSize()); for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { h.put(keys[i], values[i]); } } expandCopyParameters(h); this.values = h.values; } IntValueMap(); IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { private void expand() { IntValueMap<T> h = new IntValueMap<>(newSize()); for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { h.put(keys[i], values[i]); } } expandCopyParameters(h); this.values = h.values; } IntValueMap(); IntValueMap(int size); int add...
IntValueMap extends HashBase<T> implements Iterable<T> { private void expand() { IntValueMap<T> h = new IntValueMap<>(newSize()); for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { h.put(keys[i], values[i]); } } expandCopyParameters(h); this.values = h.values; } IntValueMap(); IntValueMap(int size); int add...
@Test public void getTest() { IntValueMap<Integer> table = new IntValueMap<>(); table.put(1, 2); Assert.assertEquals(2, table.get(1)); Assert.assertEquals(0, table.get(2)); table.put(1, 3); Assert.assertEquals(3, table.get(1)); table = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { table.put(i, i + 1); } for (in...
public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (sl...
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue;...
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue;...
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue;...
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue;...