diff --git a/.classpath b/.classpath index c1c6235..33801f9 100644 --- a/.classpath +++ b/.classpath @@ -2,7 +2,11 @@ - + + + + + diff --git a/.pmd b/.pmd new file mode 100644 index 0000000..05e7cb7 --- /dev/null +++ b/.pmd @@ -0,0 +1,1711 @@ + + + false + + + + + ApexAssertionsShouldIncludeMessage + Best Practices + + + ApexUnitTestClassShouldHaveAsserts + Best Practices + + + ApexUnitTestClassShouldHaveRunAs + Best Practices + + + ApexUnitTestMethodShouldHaveIsTestAnnotation + Best Practices + + + ApexUnitTestShouldNotUseSeeAllDataTrue + Best Practices + + + AvoidGlobalModifier + Best Practices + + + AvoidLogicInTrigger + Best Practices + + + DebugsShouldUseLoggingLevel + Best Practices + + + UnusedLocalVariable + Best Practices + + + ClassNamingConventions + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + FieldDeclarationsShouldBeAtStart + Code Style + + + FieldNamingConventions + Code Style + + + ForLoopsMustUseBraces + Code Style + + + FormalParameterNamingConventions + Code Style + + + LocalVariableNamingConventions + Code Style + + + MethodNamingConventions + Code Style + + + OneDeclarationPerLine + Code Style + + + PropertyNamingConventions + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + AvoidDeeplyNestedIfStmts + Design + + + UnusedMethod + Design + + + CyclomaticComplexity + Design + + + CognitiveComplexity + Design + + + ExcessiveClassLength + Design + + + ExcessiveParameterList + Design + + + ExcessivePublicCount + Design + + + NcssConstructorCount + Design + + + NcssMethodCount + Design + + + NcssTypeCount + Design + + + StdCyclomaticComplexity + Design + + + TooManyFields + Design + + + ApexDoc + Documentation + + + ApexCSRF + Error Prone + + + AvoidDirectAccessTriggerMap + Error Prone + + + AvoidHardcodingId + Error Prone + + + AvoidNonExistentAnnotations + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyTryOrFinallyBlock + Error Prone + + + EmptyWhileStmt + Error Prone + + + InaccessibleAuraEnabledGetter + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + TestMethodsMustBeInTestClasses + Error Prone + + + AvoidDebugStatements + Performance + + + AvoidDmlStatementsInLoops + Performance + + + AvoidSoqlInLoops + Performance + + + AvoidSoslInLoops + Performance + + + EagerlyLoadedDescribeSObjectResult + Performance + + + OperationWithLimitsInLoop + Performance + + + ApexBadCrypto + Security + + + ApexCRUDViolation + Security + + + ApexDangerousMethods + Security + + + ApexInsecureEndpoint + Security + + + ApexOpenRedirect + Security + + + ApexSharingViolations + Security + + + ApexSOQLInjection + Security + + + ApexSuggestUsingNamedCred + Security + + + ApexXSSFromEscapeFalse + Security + + + ApexXSSFromURLParam + Security + + + AvoidWithStatement + Best Practices + + + ConsistentReturn + Best Practices + + + GlobalVariable + Best Practices + + + ScopeForInVariable + Best Practices + + + UseBaseWithParseInt + Best Practices + + + AssignmentInOperand + Code Style + + + ForLoopsMustUseBraces + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + NoElseReturn + Code Style + + + UnnecessaryBlock + Code Style + + + UnnecessaryParentheses + Code Style + + + UnreachableCode + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + AvoidTrailingComma + Error Prone + + + EqualComparison + Error Prone + + + InnaccurateNumericLiteral + Error Prone + + + AvoidInlineStyles + Best Practices + + + UnnecessaryTypeAttribute + Best Practices + + + UseAltAttributeForImages + Best Practices + + + AbstractClassWithoutAbstractMethod + Best Practices + + + AccessorClassGeneration + Best Practices + + + AccessorMethodGeneration + Best Practices + + + ArrayIsStoredDirectly + Best Practices + + + AvoidMessageDigestField + Best Practices + + + AvoidPrintStackTrace + Best Practices + + + AvoidReassigningCatchVariables + Best Practices + + + AvoidReassigningLoopVariables + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidStringBufferField + Best Practices + + + AvoidUsingHardCodedIP + Best Practices + + + CheckResultSet + Best Practices + + + ConstantsInInterface + Best Practices + + + DefaultLabelNotLastInSwitchStmt + Best Practices + + + DoubleBraceInitialization + Best Practices + + + ForLoopCanBeForeach + Best Practices + + + ForLoopVariableCount + Best Practices + + + GuardLogStatement + Best Practices + + + JUnit4SuitesShouldUseSuiteAnnotation + Best Practices + + + JUnit4TestShouldUseAfterAnnotation + Best Practices + + + JUnit4TestShouldUseBeforeAnnotation + Best Practices + + + JUnit4TestShouldUseTestAnnotation + Best Practices + + + JUnit5TestShouldBePackagePrivate + Best Practices + + + JUnitAssertionsShouldIncludeMessage + Best Practices + + + JUnitTestContainsTooManyAsserts + Best Practices + + + JUnitTestsShouldIncludeAssert + Best Practices + + + JUnitUseExpected + Best Practices + + + LiteralsFirstInComparisons + Best Practices + + + LooseCoupling + Best Practices + + + MethodReturnsInternalArray + Best Practices + + + MissingOverride + Best Practices + + + OneDeclarationPerLine + Best Practices + + + PreserveStackTrace + Best Practices + + + PrimitiveWrapperInstantiation + Best Practices + + + ReplaceEnumerationWithIterator + Best Practices + + + ReplaceHashtableWithMap + Best Practices + + + ReplaceVectorWithList + Best Practices + + + SimplifiableTestAssertion + Best Practices + + + SwitchStmtsShouldHaveDefault + Best Practices + + + SystemPrintln + Best Practices + + + UnusedAssignment + Best Practices + + + UnusedFormalParameter + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedPrivateField + Best Practices + + + UnusedPrivateMethod + Best Practices + + + UseCollectionIsEmpty + Best Practices + + + UseStandardCharsets + Best Practices + + + UseTryWithResources + Best Practices + + + UseVarargs + Best Practices + + + WhileLoopWithLiteralBoolean + Best Practices + + + AtLeastOneConstructor + Code Style + + + AvoidDollarSigns + Code Style + + + AvoidProtectedFieldInFinalClass + Code Style + + + AvoidProtectedMethodInFinalClassNotExtending + Code Style + + + AvoidUsingNativeCode + Code Style + + + BooleanGetMethodName + Code Style + + + CallSuperInConstructor + Code Style + + + ClassNamingConventions + Code Style + + + CommentDefaultAccessModifier + Code Style + + + ConfusingTernary + Code Style + + + ControlStatementBraces + Code Style + + + EmptyMethodInAbstractClassShouldBeAbstract + Code Style + + + EmptyControlStatement + Code Style + + + ExtendsObject + Code Style + + + FieldDeclarationsShouldBeAtStartOfClass + Code Style + + + FieldNamingConventions + Code Style + + + FinalParameterInAbstractMethod + Code Style + + + ForLoopShouldBeWhileLoop + Code Style + + + FormalParameterNamingConventions + Code Style + + + GenericsNaming + Code Style + + + IdenticalCatchBranches + Code Style + + + LinguisticNaming + Code Style + + + LocalHomeNamingConvention + Code Style + + + LocalInterfaceSessionNamingConvention + Code Style + + + LocalVariableCouldBeFinal + Code Style + + + LocalVariableNamingConventions + Code Style + + + LongVariable + Code Style + + + MDBAndSessionBeanNamingConvention + Code Style + + + MethodArgumentCouldBeFinal + Code Style + + + MethodNamingConventions + Code Style + + + NoPackage + Code Style + + + UseUnderscoresInNumericLiterals + Code Style + + + OnlyOneReturn + Code Style + + + PackageCase + Code Style + + + PrematureDeclaration + Code Style + + + RemoteInterfaceNamingConvention + Code Style + + + RemoteSessionInterfaceNamingConvention + Code Style + + + ShortClassName + Code Style + + + ShortMethodName + Code Style + + + ShortVariable + Code Style + + + TooManyStaticImports + Code Style + + + UnnecessaryAnnotationValueElement + Code Style + + + UnnecessaryBoxing + Code Style + + + UnnecessaryCast + Code Style + + + UnnecessaryConstructor + Code Style + + + UnnecessaryFullyQualifiedName + Code Style + + + UnnecessaryImport + Code Style + + + UnnecessaryLocalBeforeReturn + Code Style + + + UnnecessaryModifier + Code Style + + + UnnecessaryReturn + Code Style + + + UnnecessarySemicolon + Code Style + + + UseDiamondOperator + Code Style + + + UselessParentheses + Code Style + + + UselessQualifiedThis + Code Style + + + UseShortArrayInitializer + Code Style + + + AbstractClassWithoutAnyMethod + Design + + + AvoidCatchingGenericException + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidRethrowingException + Design + + + AvoidThrowingNewInstanceOfSameException + Design + + + AvoidThrowingNullPointerException + Design + + + AvoidThrowingRawExceptionTypes + Design + + + AvoidUncheckedExceptionsInSignatures + Design + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + Design + + + CollapsibleIfStatements + Design + + + CouplingBetweenObjects + Design + + + CognitiveComplexity + Design + + + CyclomaticComplexity + Design + + + DataClass + Design + + + DoNotExtendJavaLangError + Design + + + ExceptionAsFlowControl + Design + + + ExcessiveClassLength + Design + + + ExcessiveImports + Design + + + ExcessiveMethodLength + Design + + + ExcessiveParameterList + Design + + + ExcessivePublicCount + Design + + + FinalFieldCouldBeStatic + Design + + + GodClass + Design + + + ImmutableField + Design + + + InvalidJavaBean + Design + + + LawOfDemeter + Design + + + LogicInversion + Design + + + LoosePackageCoupling + Design + + + NcssCount + Design + + + NPathComplexity + Design + + + SignatureDeclareThrowsException + Design + + + SimplifiedTernary + Design + + + SimplifyBooleanExpressions + Design + + + SimplifyBooleanReturns + Design + + + SimplifyConditional + Design + + + SingularField + Design + + + SwitchDensity + Design + + + TooManyFields + Design + + + TooManyMethods + Design + + + UselessOverridingMethod + Design + + + UseObjectForClearerAPI + Design + + + UseUtilityClass + Design + + + MutableStaticState + Design + + + CommentContent + Documentation + + + CommentRequired + Documentation + + + CommentSize + Documentation + + + UncommentedEmptyConstructor + Documentation + + + UncommentedEmptyMethodBody + Documentation + + + AssignmentInOperand + Error Prone + + + AssignmentToNonFinalStatic + Error Prone + + + AvoidAccessibilityAlteration + Error Prone + + + AvoidAssertAsIdentifier + Error Prone + + + AvoidBranchingStatementAsLastInLoop + Error Prone + + + AvoidCallingFinalize + Error Prone + + + AvoidCatchingNPE + Error Prone + + + AvoidCatchingThrowable + Error Prone + + + AvoidDecimalLiteralsInBigDecimalConstructor + Error Prone + + + AvoidDuplicateLiterals + Error Prone + + + AvoidEnumAsIdentifier + Error Prone + + + AvoidFieldNameMatchingMethodName + Error Prone + + + AvoidFieldNameMatchingTypeName + Error Prone + + + AvoidInstanceofChecksInCatchClause + Error Prone + + + AvoidLiteralsInIfCondition + Error Prone + + + AvoidLosingExceptionInformation + Error Prone + + + AvoidMultipleUnaryOperators + Error Prone + + + AvoidUsingOctalValues + Error Prone + + + BrokenNullCheck + Error Prone + + + CallSuperFirst + Error Prone + + + CallSuperLast + Error Prone + + + CheckSkipResult + Error Prone + + + ClassCastExceptionWithToArray + Error Prone + + + CloneMethodMustBePublic + Error Prone + + + CloneMethodMustImplementCloneable + Error Prone + + + CloneMethodReturnTypeMustMatchClassName + Error Prone + + + CloseResource + Error Prone + + + CompareObjectsWithEquals + Error Prone + + + ComparisonWithNaN + Error Prone + + + ConstructorCallsOverridableMethod + Error Prone + + + DetachedTestCase + Error Prone + + + DoNotCallGarbageCollectionExplicitly + Error Prone + + + DoNotExtendJavaLangThrowable + Error Prone + + + DoNotHardCodeSDCard + Error Prone + + + DoNotTerminateVM + Error Prone + + + DoNotThrowExceptionInFinally + Error Prone + + + DontImportSun + Error Prone + + + DontUseFloatTypeForLoopIndices + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyFinalizer + Error Prone + + + EmptyFinallyBlock + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyInitializer + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyStatementNotInLoop + Error Prone + + + EmptySwitchStatements + Error Prone + + + EmptySynchronizedBlock + Error Prone + + + EmptyTryBlock + Error Prone + + + EmptyWhileStmt + Error Prone + + + EqualsNull + Error Prone + + + FinalizeDoesNotCallSuperFinalize + Error Prone + + + FinalizeOnlyCallsSuperFinalize + Error Prone + + + FinalizeOverloaded + Error Prone + + + FinalizeShouldBeProtected + Error Prone + + + IdempotentOperations + Error Prone + + + ImplicitSwitchFallThrough + Error Prone + + + InstantiationToGetClass + Error Prone + + + InvalidLogMessageFormat + Error Prone + + + JumbledIncrementer + Error Prone + + + JUnitSpelling + Error Prone + + + JUnitStaticSuite + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MisplacedNullCheck + Error Prone + + + MissingSerialVersionUID + Error Prone + + + MissingStaticMethodInNonInstantiatableClass + Error Prone + + + MoreThanOneLogger + Error Prone + + + NonCaseLabelInSwitchStatement + Error Prone + + + NonSerializableClass + Error Prone + + + NonStaticInitializer + Error Prone + + + NullAssignment + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + ProperCloneImplementation + Error Prone + + + ProperLogger + Error Prone + + + ReturnEmptyCollectionRatherThanNull + Error Prone + + + ReturnFromFinallyBlock + Error Prone + + + SimpleDateFormatNeedsLocale + Error Prone + + + SingleMethodSingleton + Error Prone + + + SingletonClassReturningNewInstance + Error Prone + + + StaticEJBFieldShouldBeFinal + Error Prone + + + StringBufferInstantiationWithChar + Error Prone + + + SuspiciousEqualsMethodName + Error Prone + + + SuspiciousHashcodeMethodName + Error Prone + + + SuspiciousOctalEscape + Error Prone + + + TestClassWithoutTestCases + Error Prone + + + UnconditionalIfStatement + Error Prone + + + UnnecessaryBooleanAssertion + Error Prone + + + UnnecessaryCaseChange + Error Prone + + + UnnecessaryConversionTemporary + Error Prone + + + UnusedNullCheckInEquals + Error Prone + + + UseCorrectExceptionLogging + Error Prone + + + UseEqualsToCompareStrings + Error Prone + + + UselessOperationOnImmutable + Error Prone + + + UseLocaleWithCaseConversions + Error Prone + + + UseProperClassLoader + Error Prone + + + AvoidSynchronizedAtMethodLevel + Multithreading + + + AvoidThreadGroup + Multithreading + + + AvoidUsingVolatile + Multithreading + + + DoNotUseThreads + Multithreading + + + DontCallThreadRun + Multithreading + + + DoubleCheckedLocking + Multithreading + + + NonThreadSafeSingleton + Multithreading + + + UnsynchronizedStaticFormatter + Multithreading + + + UseConcurrentHashMap + Multithreading + + + UseNotifyAllInsteadOfNotify + Multithreading + + + AddEmptyString + Performance + + + AppendCharacterWithChar + Performance + + + AvoidArrayLoops + Performance + + + AvoidCalendarDateCreation + Performance + + + AvoidFileStream + Performance + + + AvoidInstantiatingObjectsInLoops + Performance + + + BigIntegerInstantiation + Performance + + + ConsecutiveAppendsShouldReuse + Performance + + + ConsecutiveLiteralAppends + Performance + + + InefficientEmptyStringCheck + Performance + + + InefficientStringBuffering + Performance + + + InsufficientStringBufferDeclaration + Performance + + + OptimizableToArrayCall + Performance + + + RedundantFieldInitializer + Performance + + + StringInstantiation + Performance + + + StringToString + Performance + + + TooFewBranchesForASwitchStatement + Performance + + + UseArrayListInsteadOfVector + Performance + + + UseArraysAsList + Performance + + + UseIndexOfChar + Performance + + + UseIOStreamsWithApacheCommonsFileItem + Performance + + + UselessStringValueOf + Performance + + + UseStringBufferForStringAppends + Performance + + + UseStringBufferLength + Performance + + + HardCodedCryptoKey + Security + + + InsecureCryptoIv + Security + + + DontNestJsfInJstlIteration + Best Practices + + + NoClassAttribute + Best Practices + + + NoHtmlComments + Best Practices + + + NoJspForward + Best Practices + + + DuplicateJspImports + Code Style + + + NoInlineScript + Design + + + NoInlineStyleInformation + Design + + + NoLongScripts + Design + + + NoScriptlets + Design + + + JspEncoding + Error Prone + + + IframeMissingSrcAttribute + Security + + + NoUnsanitizedJSPExpression + Security + + + FunctionNameTooShort + Best Practices + + + OverrideBothEqualsAndHashcode + Error Prone + + + ClassStartNameEqualsEndName + Best Practices + + + ConnectUsingNonConnector + Best Practices + + + AmbiguousResolution + Best Practices + + + TomKytesDespair + Best Practices + + + AvoidTabCharacter + Code Style + + + CodeFormat + Code Style + + + MisplacedPragma + Code Style + + + ForLoopNaming + Code Style + + + LineLength + Code Style + + + CyclomaticComplexity + Design + + + ExcessiveMethodLength + Design + + + ExcessiveObjectLength + Design + + + ExcessivePackageBodyLength + Design + + + ExcessivePackageSpecificationLength + Design + + + ExcessiveParameterList + Design + + + ExcessiveTypeLength + Design + + + NcssMethodCount + Design + + + NcssObjectCount + Design + + + NPathComplexity + Design + + + TooManyFields + Design + + + TooManyMethods + Design + + + TO_DATE_TO_CHAR + Error Prone + + + TO_DATEWithoutDateFormat + Error Prone + + + TO_TIMESTAMPWithoutDateFormat + Error Prone + + + InvalidDependencyTypes + Error Prone + + + ProjectVersionAsDependencyVersion + Error Prone + + + ProhibitedInterfaceBuilder + Best Practices + + + UnavailableFunction + Best Practices + + + ForceCast + Error Prone + + + ForceTry + Error Prone + + + VfCsrf + Security + + + VfHtmlStyleTagXss + Security + + + VfUnescapeEl + Security + + + AvoidReassigningParameters + Best Practices + + + UnusedMacroParameter + Best Practices + + + AvoidDeeplyNestedIfStmts + Design + + + CollapsibleIfStatements + Design + + + ExcessiveTemplateLength + Design + + + NoInlineJavaScript + Design + + + NoInlineStyles + Design + + + EmptyForeachStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + MistypedCDATASection + Error Prone + + + UseConcatOnce + Code Style + + + AvoidAxisNavigation + Performance + + + false + true + true + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7341ab1..f2525a8 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/src/jwave/transforms/FastWaveletTransform.java b/src/jwave/transforms/FastWaveletTransform.java index cb4c18f..b43b2d1 100644 --- a/src/jwave/transforms/FastWaveletTransform.java +++ b/src/jwave/transforms/FastWaveletTransform.java @@ -83,13 +83,14 @@ public FastWaveletTransform( Wavelet wavelet ) { + "given level is out of range for given array" ); double[ ] arrHilb = Arrays.copyOf( arrTime, arrTime.length ); - + double[ ] arrTempPart = new double[arrTime.length]; + int l = 0; int h = arrHilb.length; int transformWavelength = _wavelet.getTransformWavelength( ); // normally 2 while( h >= transformWavelength && l < level ) { - double[ ] arrTempPart = _wavelet.forward( arrHilb, h ); + _wavelet.forward( arrHilb, h, arrTempPart ); System.arraycopy( arrTempPart, 0, arrHilb, 0, h ); h = h >> 1; l++; @@ -132,7 +133,8 @@ public FastWaveletTransform( Wavelet wavelet ) { int length = arrHilb.length; // length of first Hilbert space double[ ] arrTime = Arrays.copyOf( arrHilb, length ); - + double[ ] arrTempPart = new double[length]; + int transformWavelength = _wavelet.getTransformWavelength( ); // normally 2 int h = transformWavelength; @@ -142,7 +144,7 @@ public FastWaveletTransform( Wavelet wavelet ) { while( h <= arrTime.length && h >= transformWavelength ) { - double[ ] arrTempPart = _wavelet.reverse( arrTime, h ); + _wavelet.reverse( arrTime, h, arrTempPart ); System.arraycopy( arrTempPart, 0, arrTime, 0, h ); h = h << 1; diff --git a/src/jwave/transforms/ShiftingWaveletTransform.java b/src/jwave/transforms/ShiftingWaveletTransform.java index ebc6c0d..9dd0539 100644 --- a/src/jwave/transforms/ShiftingWaveletTransform.java +++ b/src/jwave/transforms/ShiftingWaveletTransform.java @@ -10,8 +10,6 @@ package jwave.transforms; import jwave.exceptions.JWaveException; -import jwave.exceptions.JWaveFailureNotImplemented; -import jwave.tools.MathToolKit; import jwave.transforms.wavelets.Wavelet; /** @@ -60,12 +58,12 @@ public ShiftingWaveletTransform( Wavelet wavelet ) { for( int s = 0; s < splits; s++ ) { double[ ] arrDiv = new double[ div ]; - double[ ] arrRes = null; + double[ ] arrRes = new double[ div ]; for( int p = 0; p < div; p++ ) arrDiv[ p ] = arrHilb[ s * div + p ]; - arrRes = _wavelet.forward( arrDiv, div ); + arrRes = _wavelet.forward( arrDiv, div, arrRes ); for( int q = 0; q < div; q++ ) arrHilb[ s * div + q ] = arrRes[ q ]; @@ -117,12 +115,12 @@ public ShiftingWaveletTransform( Wavelet wavelet ) { for( int s = 0; s < splits; s++ ) { double[ ] arrDiv = new double[ div ]; - double[ ] arrRes = null; + double[ ] arrRes = new double[ div ]; for( int p = 0; p < div; p++ ) arrDiv[ p ] = arrTime[ s * div + p ]; - arrRes = _wavelet.reverse( arrDiv, div ); + arrRes = _wavelet.reverse( arrDiv, div, arrRes ); for( int q = 0; q < div; q++ ) arrTime[ s * div + q ] = arrRes[ q ]; diff --git a/src/jwave/transforms/WaveletPacketTransform.java b/src/jwave/transforms/WaveletPacketTransform.java index a198cdf..4cfdd55 100644 --- a/src/jwave/transforms/WaveletPacketTransform.java +++ b/src/jwave/transforms/WaveletPacketTransform.java @@ -83,10 +83,10 @@ public WaveletPacketTransform( Wavelet wavelet ) { throw new JWaveFailure( "WaveletPacketTransform#forward - given level is out of range for given array" ); - double[ ] arrHilb = new double[ arrTime.length ]; - for( int i = 0; i < arrTime.length; i++ ) - arrHilb[ i ] = arrTime[ i ]; - + double[ ] arrHilb = Arrays.copyOf( arrTime, arrTime.length ); + double[ ] iBuf = new double[ arrTime.length ]; + double[ ] oBuf = new double[arrTime.length]; + int k = arrTime.length; int h = arrTime.length; @@ -101,12 +101,10 @@ public WaveletPacketTransform( Wavelet wavelet ) { for( int p = 0; p < g; p++ ) { - double[ ] iBuf = new double[ h ]; - for( int i = 0; i < h; i++ ) iBuf[ i ] = arrHilb[ i + ( p * h ) ]; - double[ ] oBuf = _wavelet.forward( iBuf, h ); + _wavelet.forward( iBuf, h, oBuf ); for( int i = 0; i < h; i++ ) arrHilb[ i + ( p * h ) ] = oBuf[ i ]; @@ -153,6 +151,8 @@ public WaveletPacketTransform( Wavelet wavelet ) { int length = arrHilb.length; // length of first Hilbert space double[ ] arrTime = Arrays.copyOf( arrHilb, length ); + double[ ] iBuf = new double[ length ]; + double[ ] oBuf = new double[length]; int transformWavelength = _wavelet.getTransformWavelength( ); // 2, 4, 8, 16, 32, ... @@ -170,12 +170,10 @@ public WaveletPacketTransform( Wavelet wavelet ) { for( int p = 0; p < g; p++ ) { - double[ ] iBuf = new double[ h ]; - for( int i = 0; i < h; i++ ) iBuf[ i ] = arrTime[ i + ( p * h ) ]; - double[ ] oBuf = _wavelet.reverse( iBuf, h ); + _wavelet.reverse( iBuf, h, oBuf ); for( int i = 0; i < h; i++ ) arrTime[ i + ( p * h ) ] = oBuf[ i ]; diff --git a/src/jwave/transforms/wavelets/Wavelet.java b/src/jwave/transforms/wavelets/Wavelet.java index 4f51a98..a4741d9 100644 --- a/src/jwave/transforms/wavelets/Wavelet.java +++ b/src/jwave/transforms/wavelets/Wavelet.java @@ -233,11 +233,8 @@ public int getTransformWavelength( ) { * full length of arrTime! * @return coefficients represented by frequency domain */ - public double[ ] forward( double[ ] arrTime, int arrTimeLength ) { - - double[ ] arrHilb = new double[ arrTimeLength ]; - - int h = arrHilb.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength + public double[ ] forward( double[ ] arrTime, int arrTimeLength, double[ ] arrHilb ) { + int h = arrTimeLength >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for( int i = 0; i < h; i++ ) { arrHilb[ i ] = arrHilb[ i + h ] = 0.; // set to zero before sum up @@ -245,8 +242,8 @@ public int getTransformWavelength( ) { for( int j = 0; j < _motherWavelength; j++ ) { int k = ( i << 1 ) + j; // k = ( i * 2 ) + j; - while( k >= arrHilb.length ) - k -= arrHilb.length; // circulate over arrays if scaling and wavelet are are larger + while( k >= arrTimeLength ) + k -= arrTimeLength; // circulate over arrays if scaling and wavelet are are larger arrHilb[ i ] += arrTime[ k ] * _scalingDeCom[ j ]; // low pass filter for the energy (approximation) arrHilb[ i + h ] += arrTime[ k ] * _waveletDeCom[ j ]; // high pass filter for the details @@ -274,20 +271,18 @@ public int getTransformWavelength( ) { * full length of arrHilb! * @return coefficients represented by time domain */ - public double[ ] reverse( double[ ] arrHilb, int arrHilbLength ) { - - double[ ] arrTime = new double[ arrHilbLength ]; - for( int i = 0; i < arrTime.length; i++ ) + public double[ ] reverse( double[ ] arrHilb, int arrHilbLength, double[ ] arrTime ) { + for( int i = 0; i < arrHilbLength; i++ ) arrTime[ i ] = 0.; // set to zero before sum up - int h = arrTime.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength + int h = arrHilbLength >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for( int i = 0; i < h; i++ ) { for( int j = 0; j < _motherWavelength; j++ ) { int k = ( i << 1 ) + j; // k = ( i * 2 ) + j; - while( k >= arrTime.length ) - k -= arrTime.length; // circulate over arrays if scaling and wavelet are larger + while( k >= arrHilbLength ) + k -= arrHilbLength; // circulate over arrays if scaling and wavelet are larger // adding up energy from low pass (approximation) and details from high pass filter arrTime[ k ] += diff --git a/src/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java b/src/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java index c91e2d8..7a0e79a 100644 --- a/src/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java +++ b/src/jwave/transforms/wavelets/biorthogonal/BiOrthogonal.java @@ -71,11 +71,9 @@ protected void _buildBiOrthonormalSpace( ) { * @date 28.03.2015 18:44:24 (non-Javadoc) * @see jwave.transforms.wavelets.Wavelet#forward(double[], int) */ - @Override public double[ ] forward( double[ ] arrTime, int arrTimeLength ) { + @Override public double[ ] forward( double[ ] arrTime, int arrTimeLength, double[ ] arrHilb ) { - double[ ] arrHilb = new double[ arrTimeLength ]; - - int h = arrHilb.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength + int h = arrTimeLength >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for( int i = 0; i < h; i++ ) { arrHilb[ i ] = arrHilb[ i + h ] = 0.; // set to zero before sum up @@ -83,8 +81,8 @@ protected void _buildBiOrthonormalSpace( ) { for( int j = 0; j < _motherWavelength; j++ ) { int k = ( i << 1 ) + j; // k = ( i * 2 ) + j; - while( k >= arrHilb.length ) - k -= arrHilb.length; // circulate over arrays if scaling and wavelet are are larger + while( k >= arrTimeLength ) + k -= arrTimeLength; // circulate over arrays if scaling and wavelet are are larger arrHilb[ i ] += arrTime[ k ] * _scalingDeCom[ j ]; // low pass filter for the energy (approximation) arrHilb[ i + h ] += arrTime[ k ] * _waveletDeCom[ j ]; // high pass filter for the details @@ -104,20 +102,20 @@ protected void _buildBiOrthonormalSpace( ) { * @date 28.03.2015 18:44:24 (non-Javadoc) * @see jwave.transforms.wavelets.Wavelet#reverse(double[], int) */ - @Override public double[ ] reverse( double[ ] arrHilb, int arrHilbLength ) { + @Override public double[ ] reverse( double[ ] arrHilb, int arrHilbLength, double[ ] arrTime ) { - double[ ] arrTime = new double[ arrHilbLength ]; - for( int i = 0; i < arrTime.length; i++ ) + // double[ ] arrTime = new double[ arrHilbLength ]; + for( int i = 0; i < arrHilbLength; i++ ) arrTime[ i ] = 0.; - int h = arrTime.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength + int h = arrHilbLength >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for( int i = 0; i < h; i++ ) { for( int j = 0; j < _motherWavelength; j++ ) { int k = ( i << 1 ) + j; // k = ( i * 2 ) + j; - while( k >= arrTime.length ) - k -= arrTime.length; // circulate over arrays if scaling and wavelet are larger + while( k >= arrHilbLength ) + k -= arrHilbLength; // circulate over arrays if scaling and wavelet are larger // adding up energy from low pass (approximation) and details from high pass filter arrTime[ k ] += diff --git a/src/jwave/transforms/wavelets/haar/Haar1Orthogonal.java b/src/jwave/transforms/wavelets/haar/Haar1Orthogonal.java index f2d01dc..2be6cf1 100644 --- a/src/jwave/transforms/wavelets/haar/Haar1Orthogonal.java +++ b/src/jwave/transforms/wavelets/haar/Haar1Orthogonal.java @@ -172,14 +172,12 @@ public Haar1Orthogonal( ) { * @author Christian (graetz23@gmail.com) * @date 15.02.2014 21:17:22 */ - @Override public double[ ] reverse( double[ ] arrHilb, int arrHilbLength ) { + @Override public double[ ] reverse( double[ ] arrHilb, int arrHilbLength, double[ ] arrTime ) { - double[ ] arrTime = new double[ arrHilbLength ]; - - for( int i = 0; i < arrTime.length; i++ ) + for( int i = 0; i < arrHilbLength; i++ ) arrTime[ i ] = 0.; - int h = arrTime.length >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength + int h = arrHilbLength >> 1; // .. -> 8 -> 4 -> 2 .. shrinks in each step by half wavelength for( int i = 0; i < h; i++ ) { @@ -187,8 +185,8 @@ public Haar1Orthogonal( ) { int k = ( i * 2 ) + j; // int k = ( i << 1 ) + j; - while( k >= arrTime.length ) - k -= arrTime.length; // circulate over arrays if scaling and wavelet are larger + while( k >= arrHilbLength ) + k -= arrHilbLength; // circulate over arrays if scaling and wavelet are larger // adding up energy from scaling coefficients, the low pass (approximation) filter, and // wavelet coefficients, the high pass filter (details). However, the raised energy has