├── .circleci └── config.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.asciidoc ├── build.gradle ├── docs └── README.md ├── fileheader.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── profiling └── profiling.xlsx └── src ├── asciidoc ├── 010-core-features.asciidoc ├── 020-tensors.asciidoc ├── 030-tensor-operations.asciidoc ├── 200-mathematical-remarks.asciidoc ├── 800-tensorics-quickstart.asciidoc └── 900-the-rest.asciidoc ├── examples └── org │ └── tensorics │ └── core │ └── examples │ ├── BooleanStepFunctionExample.java │ ├── MultibeamOrbit.java │ ├── Signal.java │ ├── TensorCreationExamples.java │ ├── WorkingWithTensors.java │ ├── meteo │ ├── domain │ │ ├── City.java │ │ ├── EuropeanCapital.java │ │ ├── Pressure.java │ │ ├── Sampling.java │ │ ├── Temperature.java │ │ ├── TimeRange.java │ │ └── coordinates │ │ │ ├── Latitude.java │ │ │ ├── Longitude.java │ │ │ ├── MeteoCoordinate.java │ │ │ └── Time.java │ ├── externaldata │ │ ├── FakeMeteoDataImporter.java │ │ └── MeteoDataImporterTest.java │ ├── history │ │ ├── AbstractWeatherHistory.java │ │ └── WeatherHistoryInEurope.java │ ├── icalepcs17 │ │ ├── City.java │ │ ├── Constants.java │ │ └── Time.java │ └── simple │ │ ├── City.java │ │ ├── Day.java │ │ └── SimpleMeteoExample.java │ ├── scripting │ └── ScriptingExample.java │ └── sprint │ ├── NumberOfDay.java │ ├── SprintExample.java │ └── Team.java ├── java └── org │ └── tensorics │ ├── core │ ├── analysis │ │ ├── AnalysisModule.java │ │ ├── AnalysisResult.java │ │ ├── AssertionBuilder.java │ │ ├── AssertionResult.java │ │ ├── AssertionStatus.java │ │ ├── ConditionBuilder.java │ │ ├── EnablingConditionBuilder.java │ │ ├── expression │ │ │ ├── AnalysisExpression.java │ │ │ ├── AssertionExpression.java │ │ │ └── PreconditionExpression.java │ │ ├── lang │ │ │ ├── IterableBooleanConversion.java │ │ │ ├── OngoingAllBooleanCondition.java │ │ │ ├── OngoingAllBooleanExcludableCondition.java │ │ │ ├── OngoingAnalysisEnabler.java │ │ │ ├── OngoingAnyBooleanCondition.java │ │ │ ├── OngoingBooleanCondition.java │ │ │ ├── OngoingCondition.java │ │ │ ├── OngoingNamedCondition.java │ │ │ └── OngoingPrecondition.java │ │ ├── resolver │ │ │ ├── AnalysisResolver.java │ │ │ └── AssertionResolver.java │ │ └── util │ │ │ └── Predicates.java │ ├── booleans │ │ ├── BooleanSupport.java │ │ ├── ScalarBooleanSupport.java │ │ ├── TensorBooleanSupport.java │ │ ├── lang │ │ │ ├── OngoingBooleanScalarOperation.java │ │ │ ├── OngoingBooleanTensorOperation.java │ │ │ └── OngoingDetection.java │ │ └── operations │ │ │ ├── And.java │ │ │ ├── BooleanOperations.java │ │ │ ├── BooleanTensorOperationsRepository.java │ │ │ ├── Or.java │ │ │ └── TensorChangeDetectionOperation.java │ ├── commons │ │ ├── lang │ │ │ ├── BasicOperationSupport.java │ │ │ ├── OngoingBinaryOperation.java │ │ │ └── OngoingOperation.java │ │ ├── operations │ │ │ ├── Conversion.java │ │ │ └── Conversions.java │ │ ├── options │ │ │ ├── Environment.java │ │ │ ├── ImmutableOptionRegistry.java │ │ │ ├── ManipulationOption.java │ │ │ ├── Option.java │ │ │ └── OptionRegistry.java │ │ └── util │ │ │ ├── AbstractPair.java │ │ │ ├── Named.java │ │ │ └── ValuePair.java │ ├── expressions │ │ ├── BinaryOperationExpression.java │ │ ├── BinaryPredicateExpression.java │ │ ├── ConversionOperationExpression.java │ │ ├── CreationOperationExpression.java │ │ ├── IsEqualToExpression.java │ │ ├── IsNotEqualExpression.java │ │ ├── IterableResolvingExpression.java │ │ ├── LatestOfExpression.java │ │ ├── Placeholder.java │ │ ├── PredicateExpression.java │ │ └── UnaryOperationExpression.java │ ├── fields │ │ └── doubles │ │ │ ├── AbstractOrderedField.java │ │ │ ├── DoubleCheating.java │ │ │ ├── DoubleField.java │ │ │ ├── DoubleMath.java │ │ │ ├── DoubleStatistics.java │ │ │ └── Structures.java │ ├── function │ │ ├── ContinuousFunction.java │ │ ├── CoordinateToPositionFunction.java │ │ ├── DefaultInterpolatedFunction.java │ │ ├── DiscreteFunction.java │ │ ├── DiscreteFunctionBuilder.java │ │ ├── IllegalDiscreteFunctionUsageException.java │ │ ├── InterpolatedFunction.java │ │ ├── MapBackedDiscreteFunction.java │ │ ├── MathFunction.java │ │ ├── MathFunctions.java │ │ ├── PositionToScalarFunction.java │ │ ├── TensoricFunctions.java │ │ ├── expressions │ │ │ └── DiscreteFunctionToIterableExpression.java │ │ ├── interpolation │ │ │ ├── InterpolationStrategy.java │ │ │ └── LinearInterpolationStrategy.java │ │ ├── lang │ │ │ ├── FunctionExpressionSupport.java │ │ │ ├── FunctionExpressionSupportWithConversionAndComparator.java │ │ │ ├── FunctionSupport.java │ │ │ ├── FunctionSupportWithConversionAndComparator.java │ │ │ ├── OngoingDeferredDiscreteFunctionBinaryOperation.java │ │ │ └── OngoingDiscreteFunctionBinaryOperation.java │ │ └── operations │ │ │ ├── AbstractDiscreteFunctionBinaryOperation.java │ │ │ ├── CodomainExtraction.java │ │ │ ├── DiscreteFunctionAddition.java │ │ │ ├── DiscreteFunctionDivision.java │ │ │ ├── DiscreteFunctionMultiplication.java │ │ │ ├── DiscreteFunctionOperationRepository.java │ │ │ └── DiscreteFunctionSubtraction.java │ ├── functional │ │ ├── FiniteArgumentFunction.java │ │ ├── Func1.java │ │ ├── Func2.java │ │ ├── Func3.java │ │ ├── Func4.java │ │ ├── Func5.java │ │ ├── Func6.java │ │ ├── Func7.java │ │ ├── Func8.java │ │ ├── Func9.java │ │ ├── FuncN.java │ │ └── expressions │ │ │ └── FunctionalExpression.java │ ├── iterable │ │ ├── expressions │ │ │ ├── AnyIterableConversionExpression.java │ │ │ ├── BinaryPredicateIterableExpression.java │ │ │ ├── IterableExpressionToIterable.java │ │ │ ├── IterableOperationExpression.java │ │ │ └── PickExpression.java │ │ ├── lang │ │ │ ├── IterableOperationRepository.java │ │ │ ├── OngoingDeferredIterableBinaryPredicate.java │ │ │ ├── OngoingQuantityIterableValueExtraction.java │ │ │ ├── QuantityIterableExpressionSupport.java │ │ │ ├── QuantityIterableSupport.java │ │ │ ├── ScalarIterableExpressionSupport.java │ │ │ └── ScalarIterableSupport.java │ │ └── operations │ │ │ ├── IterableAverage.java │ │ │ ├── IterableOperation.java │ │ │ ├── IterableOperations.java │ │ │ ├── IterableRms.java │ │ │ ├── IterableSize.java │ │ │ ├── IterableStd.java │ │ │ ├── IterableSum.java │ │ │ ├── IterableSumOfSquares.java │ │ │ └── IterableVar.java │ ├── lang │ │ ├── DoubleScript.java │ │ ├── EnvironmentImpl.java │ │ ├── ManipulationOptions.java │ │ ├── OngoingBasicDeferredBinaryPredicate.java │ │ ├── QuantityDoubleSupport.java │ │ ├── TensoricBooleanExpressions.java │ │ ├── TensoricDoubleExpressionSupport.java │ │ ├── TensoricDoubleExpressions.java │ │ ├── TensoricDoubleSupport.java │ │ ├── TensoricDoubles.java │ │ ├── TensoricExpressionSupport.java │ │ ├── TensoricExpressions.java │ │ ├── TensoricScript.java │ │ ├── TensoricSupport.java │ │ ├── TensoricTask.java │ │ └── Tensorics.java │ ├── math │ │ ├── AndBinaryPredicateView.java │ │ ├── BinaryPredicates.java │ │ ├── Cheating.java │ │ ├── ExplicitField.java │ │ ├── ExtendedField.java │ │ ├── InvertedBinaryPredicateView.java │ │ ├── Math.java │ │ ├── NegatedBinaryPredicateView.java │ │ ├── Operations.java │ │ ├── impl │ │ │ ├── ExplicitFieldImpl.java │ │ │ └── ExtendedFieldImpl.java │ │ ├── operations │ │ │ ├── AssociativeOperation.java │ │ │ ├── BinaryFunction.java │ │ │ ├── BinaryOperation.java │ │ │ ├── CommutativeAssociativeOperation.java │ │ │ ├── CommutativeOperation.java │ │ │ ├── CreationOperation.java │ │ │ └── UnaryOperation.java │ │ ├── predicates │ │ │ ├── BinaryPredicate.java │ │ │ ├── IsEqualTo.java │ │ │ └── IsNotEqualTo.java │ │ └── structures │ │ │ ├── Structure.java │ │ │ ├── grouplike │ │ │ ├── AbelianGroup.java │ │ │ ├── AbstractAbelianGroup.java │ │ │ ├── CommutativeMonoid.java │ │ │ ├── CommutativeSemigroup.java │ │ │ ├── FiniteStructure.java │ │ │ ├── Group.java │ │ │ ├── GrouplikeStructure.java │ │ │ ├── Magma.java │ │ │ ├── Monoid.java │ │ │ └── Semigroup.java │ │ │ └── ringlike │ │ │ ├── Field.java │ │ │ ├── OrderedField.java │ │ │ ├── Ring.java │ │ │ ├── RinglikeStructure.java │ │ │ └── Semiring.java │ ├── quantity │ │ ├── ErronousValue.java │ │ ├── ImmutableErronousValue.java │ │ ├── ImmutableQuantifiedValue.java │ │ ├── Quantified.java │ │ ├── QuantifiedValue.java │ │ ├── ValidityAware.java │ │ ├── conditions │ │ │ ├── AbstractQuantityStatisticPredicate.java │ │ │ ├── QuantityGreaterPredicate.java │ │ │ ├── QuantityLessPredicate.java │ │ │ └── QuantityPedicateRepository.java │ │ ├── lang │ │ │ ├── OngoingDeferredQuantifiedScalarOperation.java │ │ │ ├── OngoingQuantifiedScalarBinaryPredicate.java │ │ │ ├── OngoingQuantifiedScalarConversion.java │ │ │ ├── OngoingQuantifiedScalarOperation.java │ │ │ ├── OngoingQuantityValueExtraction.java │ │ │ ├── QuantityExpressionSupport.java │ │ │ └── QuantitySupport.java │ │ ├── operations │ │ │ ├── AbstractQuantityOperation.java │ │ │ ├── QuantityAbsoluteValue.java │ │ │ ├── QuantityAddition.java │ │ │ ├── QuantityAdditiveInversion.java │ │ │ ├── QuantityBinaryOperation.java │ │ │ ├── QuantityDivision.java │ │ │ ├── QuantityMultiplication.java │ │ │ ├── QuantityMultiplicativeInversion.java │ │ │ ├── QuantityOperationRepository.java │ │ │ ├── QuantitySubtraction.java │ │ │ ├── QuantitySumOrDifferenceOperation.java │ │ │ └── QuantityUnaryOperation.java │ │ └── options │ │ │ ├── BinaryOperationValidityStrategy.java │ │ │ ├── ConfidenceLevel.java │ │ │ ├── ErrorPropagationStrategy.java │ │ │ ├── ImmutableConfidenceLevel.java │ │ │ ├── JScienceQuantificationStrategy.java │ │ │ ├── OperandPair.java │ │ │ ├── QuantificationStrategy.java │ │ │ ├── QuantityEnvironment.java │ │ │ ├── RequireBothValidStrategy.java │ │ │ ├── ThrowIfOneInvalidStrategy.java │ │ │ └── UncorrelatedErrorPropagationStrategy.java │ ├── reduction │ │ ├── AbstractInterpolationStrategy.java │ │ ├── AbstractLinearDoubleInterpolationStrategy.java │ │ ├── Averaging.java │ │ ├── InterpolatedSlicing.java │ │ ├── InterpolationStrategy.java │ │ ├── LinearInterpolation.java │ │ ├── ReductionStrategy.java │ │ ├── RootMeanSquare.java │ │ ├── Slicing.java │ │ └── ToFunctions.java │ ├── resolve │ │ ├── domain │ │ │ ├── DetailedExpressionResult.java │ │ │ ├── ExceptionHandlingRequest.java │ │ │ └── ResolvingException.java │ │ ├── engine │ │ │ ├── BiggestSubTreeDispatcher.java │ │ │ ├── DefaultResolvingEngine.java │ │ │ ├── Dispatcher.java │ │ │ ├── EmergencyAbortLimitReachedException.java │ │ │ ├── ResolvedContextDidNotGrowException.java │ │ │ ├── ResolvingEngine.java │ │ │ └── ResolvingEngines.java │ │ ├── options │ │ │ ├── AbstractExceptionHandlingStrategy.java │ │ │ ├── ExceptionHandlingStrategy.java │ │ │ ├── HandleWithFirstCapableAncestorStrategy.java │ │ │ ├── ResolverSelectionStrategy.java │ │ │ ├── ResolvingOption.java │ │ │ ├── ResolvingOptions.java │ │ │ ├── RethrowExceptionHandlingStrategy.java │ │ │ └── TakeFirstResolverSelectionStrategy.java │ │ └── resolvers │ │ │ ├── AbstractResolver.java │ │ │ ├── BinaryOperationResolver.java │ │ │ ├── BinaryPredicateIterableResolver.java │ │ │ ├── BinaryPredicateResolver.java │ │ │ ├── ConversionOperationResolver.java │ │ │ ├── CreationOperationResolver.java │ │ │ ├── FunctionalExpressionResolver.java │ │ │ ├── IterableExpressionToIterableResolver.java │ │ │ ├── IterableResolvingExpressionResolver.java │ │ │ ├── ListBackedResolverRepository.java │ │ │ ├── PickResolver.java │ │ │ ├── PredicateConditionResolver.java │ │ │ ├── Resolver.java │ │ │ ├── ResolverRepository.java │ │ │ ├── Resolvers.java │ │ │ ├── TensoricScriptResolver.java │ │ │ └── UnaryOperationResolver.java │ ├── scalar │ │ └── lang │ │ │ ├── OngoingDeferredBinaryOperation.java │ │ │ ├── OngoingDeferredBinaryPredicate.java │ │ │ ├── OngoingScalarBinaryOperation.java │ │ │ ├── OngoingScalarBinaryPredicate.java │ │ │ ├── ScalarExpressionSupport.java │ │ │ └── ScalarSupport.java │ ├── tensor │ │ ├── AbstractScalar.java │ │ ├── AbstractTensor.java │ │ ├── AbstractTensorBuilder.java │ │ ├── BroadcastedTensorView.java │ │ ├── Coordinates.java │ │ ├── ImmutableScalar.java │ │ ├── ImmutableTensor.java │ │ ├── Mappable.java │ │ ├── MappableTensor.java │ │ ├── Position.java │ │ ├── PositionPair.java │ │ ├── Positions.java │ │ ├── Scalar.java │ │ ├── Shape.java │ │ ├── Shapes.java │ │ ├── Tensor.java │ │ ├── TensorBuilder.java │ │ ├── TensorPair.java │ │ ├── TensorView.java │ │ ├── Tensoric.java │ │ ├── VerificationCallback.java │ │ ├── coordinates │ │ │ └── PositionOrdering.java │ │ ├── doc-files │ │ │ ├── base-hierarchy.png │ │ │ └── base-hierarchy.ucls │ │ ├── expressions │ │ │ └── TensorExpressions.java │ │ ├── lang │ │ │ ├── OngoingCompletion.java │ │ │ ├── OngoingDeferredQuantifiedTensorOperation.java │ │ │ ├── OngoingDeferredTensorOperation.java │ │ │ ├── OngoingDimensionFlattening.java │ │ │ ├── OngoingDimensionReduction.java │ │ │ ├── OngoingEitherGet.java │ │ │ ├── OngoingFieldAwareResampling.java │ │ │ ├── OngoingFieldAwareResamplingStart.java │ │ │ ├── OngoingFlattening.java │ │ │ ├── OngoingInterpolation.java │ │ │ ├── OngoingOrderedFlattening.java │ │ │ ├── OngoingQuantifiedTensorOperation.java │ │ │ ├── OngoingQuantityTensorValueExtraction.java │ │ │ ├── OngoingResampling.java │ │ │ ├── OngoingResamplingStart.java │ │ │ ├── OngoingStructuralReduction.java │ │ │ ├── OngoingTensorFiltering.java │ │ │ ├── OngoingTensorManipulation.java │ │ │ ├── OngoingTensorOperation.java │ │ │ ├── OngoingTensorReduction.java │ │ │ ├── QuantityTensorExpressionSupport.java │ │ │ ├── QuantityTensorSupport.java │ │ │ ├── QuantityTensors.java │ │ │ ├── TensorExpressionSupport.java │ │ │ ├── TensorStructurals.java │ │ │ └── TensorSupport.java │ │ ├── operations │ │ │ ├── ElementBinaryFunction.java │ │ │ ├── ElementBinaryOperation.java │ │ │ ├── ElementUnaryOperation.java │ │ │ ├── FunctionTensorCreationOperation.java │ │ │ ├── InnerTensorOperation.java │ │ │ ├── OngoingMapOut.java │ │ │ ├── PositionFunctions.java │ │ │ ├── SingleValueTensorCreationOperation.java │ │ │ ├── TensorInternals.java │ │ │ └── TensorReduction.java │ │ ├── options │ │ │ ├── BroadcastMissingDimensionsStrategy.java │ │ │ ├── BroadcastingStrategy.java │ │ │ ├── ContextPropagationStrategy.java │ │ │ ├── ExactShapesOrOneZeroStrategy.java │ │ │ ├── IntersectionShapingStrategy.java │ │ │ ├── LeftContextPreservedStrategy.java │ │ │ └── ShapingStrategy.java │ │ ├── package-info.java │ │ ├── resample │ │ │ ├── MultiDimensionalResampling.java │ │ │ ├── ResamplingStage.java │ │ │ ├── SingleDimensionResampler.java │ │ │ └── impl │ │ │ │ ├── FieldInterpolator.java │ │ │ │ ├── LinearInterpolationResampler.java │ │ │ │ └── RepeatingResampler.java │ │ ├── specific │ │ │ ├── ImmutableDoubleArrayBackedTensor.java │ │ │ ├── PositionIndexer.java │ │ │ └── TooLargeForArrayException.java │ │ ├── stream │ │ │ ├── AbstractTensoricCollector.java │ │ │ ├── TensorCollector.java │ │ │ ├── TensorStreamFilters.java │ │ │ ├── TensorStreamMappers.java │ │ │ ├── TensorStreams.java │ │ │ └── TensorbackedCollector.java │ │ └── variance │ │ │ ├── CoContraDimensionPair.java │ │ │ ├── CoContraDimensionPairs.java │ │ │ ├── Covariant.java │ │ │ └── Covariants.java │ ├── tensorbacked │ │ ├── AbstractTensorbacked.java │ │ ├── OngoingTensorbackedCompletion.java │ │ ├── ProxiedInterfaceTensorbackeds.java │ │ ├── SimpleTensorbackedBuilder.java │ │ ├── Tensorbacked.java │ │ ├── TensorbackedBuilder.java │ │ ├── TensorbackedInternals.java │ │ ├── Tensorbackeds.java │ │ ├── annotation │ │ │ └── Dimensions.java │ │ ├── dimtyped │ │ │ ├── DimtypedTensorbacked.java │ │ │ ├── DimtypedTensorbackedBuilder.java │ │ │ ├── DimtypedTensorbackedBuilderImpl.java │ │ │ ├── DimtypedTypes.java │ │ │ ├── Tensorbacked1d.java │ │ │ ├── Tensorbacked1dBuilder.java │ │ │ ├── Tensorbacked2d.java │ │ │ ├── Tensorbacked2dBuilder.java │ │ │ ├── Tensorbacked3d.java │ │ │ ├── Tensorbacked3dBuilder.java │ │ │ ├── Tensorbacked4d.java │ │ │ ├── Tensorbacked4dBuilder.java │ │ │ ├── Tensorbacked5d.java │ │ │ ├── Tensorbacked5dBuilder.java │ │ │ ├── TensorbackedScalar.java │ │ │ └── TensorbackedScalarBuilder.java │ │ ├── expressions │ │ │ └── TensorbackedExpressions.java │ │ ├── lang │ │ │ ├── OngoingDeferredQuantifiedTensorBackedOperation.java │ │ │ ├── OngoingDeferredTensorBackedOperation.java │ │ │ ├── OngoingQuantifiedTensorBackedOperation.java │ │ │ ├── OngoingTensorBackedOperation.java │ │ │ ├── OngoingTensorbackedConstruction.java │ │ │ ├── OngoingTensorbackedFiltering.java │ │ │ ├── QuantityTensorbackedExpressionSupport.java │ │ │ ├── QuantityTensorbackedSupport.java │ │ │ ├── TensorbackedExpressionSupport.java │ │ │ └── TensorbackedSupport.java │ │ └── operations │ │ │ ├── ElementTensorBackedUnaryOperation.java │ │ │ ├── QuantifiedElementTensorBackedUnaryOperation.java │ │ │ ├── QuantifiedTensorBackedUnaryOperation.java │ │ │ ├── TensorBackedUnaryOperation.java │ │ │ ├── TensorExtractionOperation.java │ │ │ └── TensorWrappingOperation.java │ ├── testing │ │ ├── TensoricTests.java │ │ ├── hamcrest │ │ │ ├── AllElementsEqualTo.java │ │ │ ├── ScalarIsCloseTo.java │ │ │ ├── TensorIsCloseTo.java │ │ │ └── TensoricsMatchers.java │ │ └── lang │ │ │ ├── OngoingCloseToMatcherCreation.java │ │ │ ├── TensoricDoubleTestingSupport.java │ │ │ └── TensoricTestingSupport.java │ ├── tree │ │ ├── domain │ │ │ ├── AbstractDeferredExpression.java │ │ │ ├── Contexts.java │ │ │ ├── EditableResolvingContext.java │ │ │ ├── ExceptionHandlingNode.java │ │ │ ├── Expression.java │ │ │ ├── ExpressionIsUnresolvedException.java │ │ │ ├── Node.java │ │ │ ├── Path.java │ │ │ ├── RebuildableNode.java │ │ │ ├── RebuildingContext.java │ │ │ ├── RebuildingContextImpl.java │ │ │ ├── ResolvedExpression.java │ │ │ ├── ResolvingContext.java │ │ │ └── ResolvingContextImpl.java │ │ └── walking │ │ │ ├── BottomNodeCallback.java │ │ │ ├── EveryNodeCallback.java │ │ │ ├── LoopDetectedException.java │ │ │ ├── NoMatchingNodeFoundException.java │ │ │ ├── NodeCallback.java │ │ │ ├── ParentAfterChildrenWalker.java │ │ │ ├── PathDoesNotExistException.java │ │ │ ├── SkipNodeAndSubTreesCallback.java │ │ │ ├── SkipStepDownCallback.java │ │ │ ├── StepUpCallback.java │ │ │ ├── TreeWalker.java │ │ │ └── Trees.java │ ├── units │ │ ├── JScienceUnit.java │ │ └── Unit.java │ └── util │ │ ├── Classes.java │ │ ├── Instantiator.java │ │ ├── InstantiatorType.java │ │ ├── Instantiators.java │ │ ├── JavaVersions.java │ │ ├── MoreMultisets.java │ │ ├── Reflections.java │ │ ├── SingleArgumentConstructorInstantiator.java │ │ ├── SingleArgumentFactoryMethodInstantiator.java │ │ ├── SingleArgumentInvokableInstantiator.java │ │ ├── SystemState.java │ │ ├── chains │ │ ├── AbstractChainBuilder.java │ │ ├── AbstractRecursiveRepresenter.java │ │ ├── Branch.java │ │ ├── BranchChainBuilder.java │ │ ├── CaseMatchings.java │ │ ├── Chain.java │ │ ├── Chains.java │ │ ├── ConditionedMapper.java │ │ ├── ImmutableRecursion.java │ │ └── MainChainBuilder.java │ │ └── names │ │ ├── ClasspathConstantScanner.java │ │ ├── ImmutableNameRepository.java │ │ ├── NameRepository.java │ │ └── Names.java │ └── incubate │ ├── function │ ├── AnalyticalFunction.java │ ├── ConstantFunction.java │ ├── ContinuousFunction.java │ ├── DiscreteFunction.java │ ├── DiscreteFunctionBuilder.java │ ├── ExponentialFunction.java │ ├── Functions.java │ ├── IllegalDiscreteFunctionUsageException.java │ ├── InterpolatedFunction.java │ ├── InterpolationStrategy.java │ ├── KeyValueFunction.java │ ├── LinearInterpolationStrategy.java │ └── SortedMapBackedDiscreteFunction.java │ └── spaces │ └── Metric.java └── test └── org └── tensorics ├── core ├── AllSerializableHaveUidTest.java ├── PackageReference.java ├── TransportableEntitiesFulfillContractTest.java ├── booleans │ ├── AbstractBooleanTest.java │ ├── BooleanSupportTest.java │ ├── OngoingDetectionTest.java │ └── operations │ │ └── LogicalOperationTest.java ├── expressions │ ├── LambdaExpressionsTest.java │ └── LatestOfExpressionTest.java ├── fields │ └── doubles │ │ ├── DoubleFieldTest.java │ │ └── StructuresTest.java ├── function │ ├── AbstractDiscreteFunctionVs1DTensorTest.java │ ├── DefaultInterpolatedFunctionTest.java │ ├── DiscreteFunctionVs1DTensorWithCommonCoordinatesTest.java │ ├── DiscreteFunctionVs1DTensorWithNoCommonCoordinatesTest.java │ ├── LinearInterpolationStrategyTest.java │ ├── MapBackedDiscreteFunctionTest.java │ ├── MathFunctionsTest.java │ └── lang │ │ ├── FunctionExpressionSupportTest.java │ │ └── FunctionSupportTest.java ├── iterable │ └── ScalarIterableSupportTest.java ├── lang │ ├── CoordinateRange.java │ ├── InnerProductTest.java │ ├── QuantifiedFieldUsageTest.java │ ├── QuantityDoubleSupportTest.java │ ├── TCoordinate.java │ ├── TensorBackedBySetOfTensorValuesTest.java │ ├── TensorBackedSupportTest.java │ ├── TensorBackedThreeCoordinates.java │ ├── TensorBackedTwoCoordinates.java │ ├── TensorCalculationsTest.java │ ├── TensorSize.java │ ├── TensoricDoubleExpressionsSizeOfTest.java │ ├── TensoricDoublesTest.java │ ├── TensoricExpressionsTest.java │ ├── TensoricQuantifiedDoublesTest.java │ ├── TensoricScriptTest.java │ ├── TensoricsRepeatingResamplingAcceptanceTest.java │ ├── TensorsTest.java │ ├── TestCoordinate.java │ ├── XCoordinate.java │ ├── YCoordinate.java │ └── ZCoordinate.java ├── quantity │ ├── DoubleQuantificationStrategyTest.java │ ├── ImmutableQuantifiedScalarTest.java │ ├── JScienceMiscTest.java │ └── QuantifiedPredicatesTest.java ├── reduction │ └── InterpolationAtTest.java ├── resolve │ ├── BinaryPredicateExpressionTest.java │ ├── DeferredTensorBackedCalculationTest.java │ ├── DeferredTensoricCalculationTest.java │ ├── ScalarIterableExpressionSupportTest.java │ ├── engine │ │ └── ResolvingEnginesTest.java │ └── resolvers │ │ ├── PickResolverTest.java │ │ └── ResolverRepositoriesTest.java ├── scalar │ └── ScalarSupportTest.java ├── tensor │ ├── CoordinateClassHierarchyTest.java │ ├── CoordinatesOnInterfacesTest.java │ ├── CoordinatesTest.java │ ├── ImmutableScalarTest.java │ ├── ImmutableTensorTest.java │ ├── PositionTest.java │ ├── PositionsTest.java │ ├── ShapesStrippingTest.java │ ├── ShapesTest.java │ ├── TensorEqualityTest.java │ ├── coordinates │ │ └── PositionOrderingTest.java │ ├── expressions │ │ └── TensorExpressionsTest.java │ ├── lang │ │ ├── BroadcastAllBroadcastingStrategyTest.java │ │ ├── OptionalGetTest.java │ │ └── TensorStructuralsTest.java │ ├── operations │ │ ├── OperationsTest.java │ │ └── TensorInternalsTest.java │ ├── resample │ │ └── impl │ │ │ ├── LinearInterpolationResamplerTest.java │ │ │ └── MultiDimensionalResamplingTest.java │ ├── specific │ │ └── PositionArrayIndexMappingTest.java │ ├── stream │ │ └── TensorStreamsTest.java │ └── variance │ │ ├── CoContraDimensionPairsTest.java │ │ ├── CoContraPairTest.java │ │ ├── CovariantInternalsTest.java │ │ └── CovariantTest.java ├── tensorbacked │ ├── AbstractTensorbackedTest.java │ ├── NoAnnotationPresentOrbit.java │ ├── ProxiedInterfaceTensorbackedsTest.java │ ├── TensorBackedInternalsTest.java │ ├── TensorbackedBuilderTest.java │ ├── TensorbackedsTest.java │ ├── ValueTypeDeterminationTest.java │ ├── dimtyped │ │ ├── DimtypedOperationsTest.java │ │ ├── DimtypedTensorbackedTest.java │ │ └── DimtypedTypesTest.java │ ├── expressions │ │ └── TensorbackedExpressionsTest.java │ ├── interfacebacked │ │ ├── AnyOtherOrbitIf.java │ │ ├── DimtypedAndAnnotationPresentOrbit.java │ │ └── SingleBeamOrbitIf.java │ └── orbit │ │ ├── AbstractOrbit.java │ │ ├── MultibeamOrbit.java │ │ ├── MultibeamOrbitEvolution.java │ │ ├── MultibeamQOrbit.java │ │ ├── SinglebeamOrbit.java │ │ └── coordinates │ │ ├── Beam.java │ │ ├── Bpm.java │ │ ├── OrbitCoordinate.java │ │ ├── Plane.java │ │ └── Time.java ├── testing │ ├── PojoClassFilters.java │ ├── PojoTests.java │ ├── SerializableHasUid.java │ ├── TestUtil.java │ ├── TransportableEntityFulfilled.java │ └── lang │ │ └── TensoricDoubleTestingSupportTest.java ├── tree │ ├── ParentAfterChildrenWalkerTest.java │ ├── PathWithoutMatchingNodeTest.java │ ├── TreeWithMultiplePathsTest.java │ ├── TreesExceptionTest.java │ ├── TreesTest.java │ ├── domain │ │ └── ResolvedExpressionTest.java │ └── walking │ │ └── TreesFindNodeOfClassTest.java └── util │ ├── ClassesTest.java │ ├── InstantiatorsTest.java │ ├── JavaVersionsTries.java │ ├── chains │ ├── CaseMatchingsTest.java │ ├── ChainsTest.java │ └── RecursionCaseMatchingTest.java │ └── names │ ├── ClasspathConstantScannerTest.java │ └── NamesTest.java └── incubate └── function ├── DiscreteFunctionTest.java ├── ExponentialFunctionTest.java └── FunctionsTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | product.xml 2 | deployment.key 3 | build/ 4 | out/ 5 | .idea/ 6 | .gradle/ 7 | /bin/ 8 | .classpath 9 | .project 10 | .settings/ 11 | *.log 12 | .idea/ 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | jdk: 4 | - openjdk8 5 | - openjdk11 6 | before_install: 7 | - chmod +x ./gradlew 8 | script: 9 | - ./gradlew check --stacktrace 10 | - ./gradlew jacocoTestReport 11 | before_deploy: 12 | - ./gradlew generateLicenseReport 13 | - ./gradlew javadoc 14 | - echo $SIGNING_KEY_SECRING_BASE64 | base64 --decode > ./signing.key.secring 15 | - export SIGNING_KEY_PATH=./signing.key.secring 16 | - mkdir -p projectpage 17 | - cp -rv build/reports/* projectpage 18 | - cp -rv build/docs/* projectpage 19 | - cp -rv docs/* projectpage 20 | deploy: 21 | - provider: script 22 | skip_cleanup: true 23 | script: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -DDEPLOYMENT=true 24 | on: 25 | tags: true 26 | jdk: openjdk11 27 | - provider: pages 28 | skip_cleanup: true 29 | github-token: $GITHUB_TOKEN 30 | local-dir: projectpage 31 | keep-history: false 32 | on: 33 | branch: master 34 | jdk: openjdk11 35 | after_success: 36 | - bash <(curl -s https://codecov.io/bash) 37 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | The Tensorics source code is hosted on github.com. 2 | 3 | In order to contribute, please clone the repository and create a pull request with your changes. 4 | -------------------------------------------------------------------------------- /fileheader.txt: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | POM.groupId=org.tensorics 2 | POM.artifactId=tensorics-core 3 | POM.description=Tensorics is a java framework which uses a tensor as a central object. A tensor represents a set of values placed in an N-dimensional space. Wherever you are tempted to use maps of maps, a tensor might be a good choice ;-) Tensorics provides methods to create, transform and performing calculations with those tensors. 4 | 5 | INFO.repo=https://github.com/tensorics/tensorics-core.git 6 | INFO.url=http://tensorics.org/ 7 | INFO.github=https://github.com/tensorics/tensorics-core 8 | INFO.githubIssues=https://github.com/tensorics/tensorics-core/issues 9 | INFO.licenseNameShort=Apache-2.0 10 | INFO.licenseName=The Apache License, Version 2.0 11 | INFO.licenseUrl=http://www.apache.org/licenses/LICENSE-2.0.txt 12 | INFO.mainDeveloper=tensorics-developers 13 | INFO.mainDeveloperEmail=tensorics-developers@googlegroups.com 14 | INFO.organization=tensorics 15 | 16 | SONATYPE.repoUrl=https://oss.sonatype.org/service/local/ 17 | SONATYPE.repoSnapshotsUrl=https://oss.sonatype.org/content/repositories/snapshots/ 18 | 19 | guavaVersion=30.1.1-jre -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorics/tensorics-core/18b27795070fb8a3e5b50ecb733b010de53e81f8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /profiling/profiling.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorics/tensorics-core/18b27795070fb8a3e5b50ecb733b010de53e81f8/profiling/profiling.xlsx -------------------------------------------------------------------------------- /src/asciidoc/010-core-features.asciidoc: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Core Features 4 | permalink: /projects/tensorics-core/features/ 5 | project: "Tensorics Core" 6 | --- 7 | :page-liquid: 8 | == Core Features 9 | Despite the libraries core focus is on multidimensional data treatment and its name ("tensorics") is derived from "tensor" (a multidimensional object in mathematics), it provides several additional concepts which complement each other. The features are designed to work smoothly together, but each of them can of course also be used stand-alone. Te most important ones of them are: 10 | 11 | * Tensors of arbitrary dimensionality as central object. 12 | * Tensors can have elements of any (java) type. 13 | * Structural and numerical operations on tensors. 14 | * Java internal DSL (fluent API) for all operations on scalars and tensors. 15 | * Quantities (value - unit pair). 16 | * Full support for Tensors of quantities. 17 | * Error and Validity propagation for quantities and tensors of quantities. 18 | * Scripting of all functionality with deferred execution, which opens the 19 | possibilities for parallel processing and massive distribution of calculations. 20 | * Utilities for creating decision 'chains' in java, which emulate a concept similar to case-matching in scala. 21 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/MultibeamOrbit.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples; 6 | 7 | import org.tensorics.core.tensor.Tensor; 8 | import org.tensorics.core.tensorbacked.Tensorbacked; 9 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 10 | import org.tensorics.core.tensorbacked.orbit.coordinates.Beam; 11 | import org.tensorics.core.tensorbacked.orbit.coordinates.Bpm; 12 | import org.tensorics.core.tensorbacked.orbit.coordinates.Plane; 13 | 14 | /** 15 | * Test case. Multibeam class supported with TensorBacked(Double) 16 | * 17 | * @author agorzaws 18 | */ 19 | // tag::classdef[] 20 | @Dimensions({ Beam.class, Plane.class, Bpm.class }) 21 | public class MultibeamOrbit implements Tensorbacked { 22 | 23 | private final Tensor tensor; 24 | 25 | public MultibeamOrbit(Tensor tensor) { 26 | this.tensor = tensor; 27 | } 28 | 29 | public double getValueAt(String string, Beam beam, Plane plane) { 30 | return tensor.get(beam, plane, new Bpm(string)); 31 | } 32 | 33 | @Override 34 | public Tensor tensor() { 35 | return this.tensor; 36 | } 37 | 38 | } 39 | // end::classdef[] 40 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/Signal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples; 6 | 7 | /** 8 | * Dummy signal 9 | * 10 | * @author kfuchsbe 11 | */ 12 | public final class Signal { 13 | 14 | final String name; 15 | 16 | public static Signal of(String name) { 17 | return new Signal(name); 18 | } 19 | 20 | private Signal(String name) { 21 | this.name = name; 22 | } 23 | 24 | String getName() { 25 | return name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/TensorCreationExamples.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples; 2 | 3 | import org.tensorics.core.lang.Tensorics; 4 | import org.tensorics.core.tensor.Tensor; 5 | 6 | public class TensorCreationExamples { 7 | 8 | @SuppressWarnings("unused") 9 | public static void createZeroDimensionalOfString() { 10 | // tag::zerodimensionalString[] 11 | Tensor user = Tensorics.scalarOf("user"); 12 | // end::zerodimensionalString[] 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/WorkingWithTensors.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples; 2 | 3 | import org.tensorics.core.fields.doubles.Structures; 4 | import org.tensorics.core.lang.TensoricSupport; 5 | import org.tensorics.core.lang.Tensorics; 6 | 7 | @SuppressWarnings("unused") 8 | public class WorkingWithTensors { 9 | { 10 | TensoricSupport support = Tensorics.using(Structures.doubles()); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/City.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | import org.tensorics.core.examples.meteo.domain.coordinates.Latitude; 4 | import org.tensorics.core.examples.meteo.domain.coordinates.Longitude; 5 | 6 | public interface City { 7 | 8 | Longitude getLongitude(); 9 | 10 | Latitude getLatitude(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/EuropeanCapital.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | import org.tensorics.core.examples.meteo.domain.coordinates.Latitude; 4 | import org.tensorics.core.examples.meteo.domain.coordinates.Longitude; 5 | 6 | public enum EuropeanCapital implements City { 7 | 8 | BERLIN(new Longitude(65.00), new Latitude(12.12)), 9 | 10 | PARIS(new Longitude(75.00), new Latitude(13.92)), 11 | 12 | WARSZAWA(new Longitude(65.50), new Latitude(24.12)), 13 | 14 | BERN(new Longitude(73.00), new Latitude(42.2)), 15 | 16 | LONDON(new Longitude(62.00), new Latitude(13.77)), 17 | 18 | ROMA(new Longitude(52.00), new Latitude(13.77)); 19 | 20 | private Longitude longitude; 21 | private Latitude latitude; 22 | 23 | private EuropeanCapital(Longitude longitude, Latitude latitude) { 24 | this.latitude = latitude; 25 | this.longitude = longitude; 26 | } 27 | 28 | @Override 29 | public Longitude getLongitude() { 30 | return longitude; 31 | } 32 | 33 | @Override 34 | public Latitude getLatitude() { 35 | return latitude; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/Pressure.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | import org.tensorics.core.quantity.QuantifiedValue; 4 | import org.tensorics.core.tensor.Tensor; 5 | import org.tensorics.core.tensorbacked.Tensorbacked; 6 | 7 | public class Pressure implements Tensorbacked> { 8 | 9 | private final Tensor> temperature; 10 | 11 | public Pressure(Tensor> temperature) { 12 | this.temperature = temperature; 13 | } 14 | 15 | @Override 16 | public Tensor> tensor() { 17 | return temperature; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/Sampling.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | public enum Sampling { 4 | ONE_DAY, 5 | ONE_WEEK, 6 | ONE_HOUR, 7 | ONE_SECOND 8 | } 9 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/Temperature.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | import org.tensorics.core.examples.meteo.domain.coordinates.Latitude; 4 | import org.tensorics.core.examples.meteo.domain.coordinates.Longitude; 5 | import org.tensorics.core.examples.meteo.domain.coordinates.Time; 6 | import org.tensorics.core.quantity.QuantifiedValue; 7 | import org.tensorics.core.tensor.Tensor; 8 | import org.tensorics.core.tensorbacked.Tensorbacked; 9 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 10 | 11 | @Dimensions({ Latitude.class, Longitude.class, Time.class }) 12 | public class Temperature implements Tensorbacked> { 13 | 14 | private final Tensor> temperature; 15 | 16 | public Temperature(Tensor> temperature) { 17 | this.temperature = temperature; 18 | } 19 | 20 | @Override 21 | public Tensor> tensor() { 22 | return temperature; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/TimeRange.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain; 2 | 3 | public enum TimeRange { 4 | 5 | TWO_DECADES, 6 | A_DECADE, 7 | FIVE_YEARS, 8 | A_YEAR, 9 | SIX_MONTHS, 10 | A_MONTH 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/coordinates/Latitude.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain.coordinates; 2 | 3 | public class Latitude implements MeteoCoordinate { 4 | private double lattitude; 5 | 6 | public Latitude(double lattitude) { 7 | super(); 8 | this.lattitude = lattitude; 9 | } 10 | 11 | public double getLattitude() { 12 | return lattitude; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "[lattitude=" + lattitude + "]"; 18 | } 19 | 20 | @Override 21 | public int hashCode() { 22 | final int prime = 31; 23 | int result = 1; 24 | long temp; 25 | temp = Double.doubleToLongBits(lattitude); 26 | result = prime * result + (int) (temp ^ (temp >>> 32)); 27 | return result; 28 | } 29 | 30 | @Override 31 | public boolean equals(Object obj) { 32 | if (this == obj) 33 | return true; 34 | if (obj == null) 35 | return false; 36 | if (getClass() != obj.getClass()) 37 | return false; 38 | Latitude other = (Latitude) obj; 39 | if (Double.doubleToLongBits(lattitude) != Double.doubleToLongBits(other.lattitude)) 40 | return false; 41 | return true; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/coordinates/Longitude.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain.coordinates; 2 | 3 | public class Longitude implements MeteoCoordinate { 4 | @Override 5 | public String toString() { 6 | return "[longitude=" + longitude + "]"; 7 | } 8 | 9 | @Override 10 | public int hashCode() { 11 | final int prime = 31; 12 | int result = 1; 13 | long temp; 14 | temp = Double.doubleToLongBits(longitude); 15 | result = prime * result + (int) (temp ^ (temp >>> 32)); 16 | return result; 17 | } 18 | 19 | @Override 20 | public boolean equals(Object obj) { 21 | if (this == obj) 22 | return true; 23 | if (obj == null) 24 | return false; 25 | if (getClass() != obj.getClass()) 26 | return false; 27 | Longitude other = (Longitude) obj; 28 | if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude)) 29 | return false; 30 | return true; 31 | } 32 | 33 | private double longitude; 34 | 35 | public double getLongitude() { 36 | return longitude; 37 | } 38 | 39 | public Longitude(double longitude) { 40 | super(); 41 | this.longitude = longitude; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/coordinates/MeteoCoordinate.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain.coordinates; 2 | 3 | /** 4 | * A marker interface for coordinate classes 5 | * 6 | * @author arek 7 | */ 8 | public interface MeteoCoordinate { 9 | /* marker interface for coordinate */ 10 | } 11 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/domain/coordinates/Time.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.domain.coordinates; 2 | 3 | import java.util.Date; 4 | 5 | public class Time implements MeteoCoordinate { 6 | private long time; 7 | 8 | public Time(long time) { 9 | super(); 10 | this.time = time; 11 | } 12 | 13 | public Time() { 14 | this(new Date().getTime()); 15 | } 16 | 17 | public long getTime() { 18 | return time; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "[time=" + time + "]"; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | final int prime = 31; 29 | int result = 1; 30 | result = prime * result + (int) (time ^ (time >>> 32)); 31 | return result; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object obj) { 36 | if (this == obj) 37 | return true; 38 | if (obj == null) 39 | return false; 40 | if (getClass() != obj.getClass()) 41 | return false; 42 | Time other = (Time) obj; 43 | if (time != other.time) 44 | return false; 45 | return true; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/history/AbstractWeatherHistory.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.history; 2 | 3 | import java.util.List; 4 | 5 | import org.tensorics.core.examples.meteo.domain.City; 6 | import org.tensorics.core.examples.meteo.externaldata.FakeMeteoDataImporter; 7 | import org.tensorics.core.fields.doubles.Structures; 8 | import org.tensorics.core.lang.EnvironmentImpl; 9 | import org.tensorics.core.lang.ManipulationOptions; 10 | import org.tensorics.core.lang.TensoricSupport; 11 | import org.tensorics.core.quantity.QuantifiedValue; 12 | import org.tensorics.core.tensor.Tensor; 13 | import org.tensorics.core.tensor.options.IntersectionShapingStrategy; 14 | 15 | public abstract class AbstractWeatherHistory extends TensoricSupport { 16 | 17 | public AbstractWeatherHistory() { 18 | super(EnvironmentImpl.of(Structures.doubles(), ManipulationOptions.defaultOptions(Structures.doubles())) 19 | .with(IntersectionShapingStrategy.get())); 20 | } 21 | 22 | public abstract List getCities(); 23 | 24 | // tag::import[] 25 | public Tensor> importDataForCities() { 26 | return FakeMeteoDataImporter.importFromPast(); 27 | } 28 | // end::import[] 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/icalepcs17/City.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples.meteo.icalepcs17; 6 | 7 | public class City { 8 | 9 | public static City ofName(String name) { 10 | return null; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/icalepcs17/Constants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples.meteo.icalepcs17; 6 | 7 | public class Constants { 8 | 9 | public static final City SF = City.ofName("San Francisco"); 10 | public static final City LA = City.ofName("Los Angeles"); 11 | 12 | public static final Time T1 = Time.of("2017-01-01 15:00"); 13 | public static final Time T2 = Time.of("2017-01-02 15:00"); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/icalepcs17/Time.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples.meteo.icalepcs17; 6 | 7 | public class Time { 8 | 9 | public static Time of(String time) { 10 | return null; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/simple/City.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.simple; 2 | 3 | // tag::cityEnum[] 4 | public enum City { 5 | NEW_YORK, 6 | GENEVA; 7 | } 8 | // end::cityEnum[] 9 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/meteo/simple/Day.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.examples.meteo.simple; 2 | 3 | // tag::dayEnum[] 4 | public enum Day { 5 | APRIL_1_2014, 6 | JUNE_1_2014; 7 | } 8 | // end::dayEnum[] 9 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/sprint/NumberOfDay.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples.sprint; 6 | 7 | public class NumberOfDay { 8 | 9 | private final int numberOfDays; 10 | 11 | public NumberOfDay(int numberOfDays) { 12 | this.numberOfDays = numberOfDays; 13 | } 14 | 15 | @Override 16 | public int hashCode() { 17 | final int prime = 31; 18 | int result = 1; 19 | result = prime * result + numberOfDays; 20 | return result; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object obj) { 25 | if (this == obj) 26 | return true; 27 | if (obj == null) 28 | return false; 29 | if (getClass() != obj.getClass()) 30 | return false; 31 | NumberOfDay other = (NumberOfDay) obj; 32 | if (numberOfDays != other.numberOfDays) 33 | return false; 34 | return true; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/examples/org/tensorics/core/examples/sprint/Team.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.examples.sprint; 6 | 7 | public class Team { 8 | 9 | private final int teamId; 10 | 11 | public Team(int teamId) { 12 | this.teamId = teamId; 13 | } 14 | 15 | @Override 16 | public int hashCode() { 17 | final int prime = 31; 18 | int result = 1; 19 | result = prime * result + teamId; 20 | return result; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object obj) { 25 | if (this == obj) 26 | return true; 27 | if (obj == null) 28 | return false; 29 | if (getClass() != obj.getClass()) 30 | return false; 31 | Team other = (Team) obj; 32 | if (teamId != other.teamId) 33 | return false; 34 | return true; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/AssertionStatus.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.analysis; 24 | 25 | public enum AssertionStatus { 26 | SUCCESSFUL, 27 | FAILURE, 28 | ERROR, 29 | NONAPPLICABLE; 30 | 31 | public static final AssertionStatus fromBooleanSuccessful(boolean isOk) { 32 | if (isOk) { 33 | return SUCCESSFUL; 34 | } else { 35 | return FAILURE; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/EnablingConditionBuilder.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.analysis; 24 | 25 | import org.tensorics.core.tree.domain.Expression; 26 | 27 | public class EnablingConditionBuilder extends ConditionBuilder { 28 | 29 | public Expression build() { 30 | Expression condition = super.condition(); 31 | if (condition == null) { 32 | throw new IllegalStateException( 33 | "Condition is not specified! Check the enabled() clause in analysis module for completeness!"); 34 | } 35 | return condition; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/expression/PreconditionExpression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.analysis.expression; 6 | 7 | import org.tensorics.core.commons.operations.Conversion; 8 | import org.tensorics.core.expressions.ConversionOperationExpression; 9 | import org.tensorics.core.tree.domain.Expression; 10 | 11 | /** 12 | * This expression reduces an {@link Expression} of {@link Iterable} of boolean to an {@link Expression} of a 13 | * {@link Boolean}. The conversion represents the reduction strategy that will be applied on the iterable. 14 | * 15 | * @author acalia, caguiler, kfuchsberger 16 | */ 17 | public class PreconditionExpression extends ConversionOperationExpression, Boolean> { 18 | private static final long serialVersionUID = 1L; 19 | 20 | public PreconditionExpression(Conversion, Boolean> operation, 21 | Expression> source) { 22 | super(operation, source); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/lang/IterableBooleanConversion.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.analysis.lang; 24 | 25 | import org.tensorics.core.commons.operations.Conversion; 26 | 27 | /** 28 | * Reduces an iterable of {@link Boolean} into a single {@link Boolean} value. Implementations of this interface will 29 | * define reduction strategies. 30 | * 31 | * @author acalia, caguiler, kfuchsberger 32 | */ 33 | public interface IterableBooleanConversion extends Conversion, Boolean> { 34 | /* marker interface */ 35 | } 36 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/lang/OngoingBooleanCondition.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.analysis.lang; 24 | 25 | import org.tensorics.core.analysis.ConditionBuilder; 26 | import org.tensorics.core.tree.domain.Expression; 27 | 28 | public class OngoingBooleanCondition extends OngoingCondition { 29 | 30 | public OngoingBooleanCondition(ConditionBuilder builder, Expression source) { 31 | super(builder, source); 32 | } 33 | 34 | public OngoingNamedCondition isTrue() { 35 | isEqualTo(true); 36 | return this; 37 | } 38 | 39 | public OngoingNamedCondition isFalse() { 40 | isEqualTo(false); 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/analysis/util/Predicates.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.analysis.util; 24 | 25 | import java.util.function.Predicate; 26 | 27 | public final class Predicates { 28 | 29 | private Predicates() { 30 | /* only static methods */ 31 | } 32 | 33 | public static Predicate not(Predicate predicate) { 34 | return predicate.negate(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/booleans/ScalarBooleanSupport.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.booleans; 2 | 3 | import org.tensorics.core.booleans.lang.OngoingBooleanScalarOperation; 4 | 5 | /** 6 | * Support class for the Scalar boolean operations
7 | * Note: Use through the delegation class {@link BooleanSupport} 8 | * 9 | * @author agorzaws 10 | */ 11 | public class ScalarBooleanSupport { 12 | 13 | public OngoingBooleanScalarOperation calcLogical(Boolean left) { 14 | return new OngoingBooleanScalarOperation(left); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/booleans/TensorBooleanSupport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.booleans; 6 | 7 | import static java.util.Objects.requireNonNull; 8 | 9 | import org.tensorics.core.booleans.lang.OngoingBooleanTensorOperation; 10 | import org.tensorics.core.booleans.lang.OngoingDetection; 11 | import org.tensorics.core.commons.options.ManipulationOption; 12 | import org.tensorics.core.commons.options.OptionRegistry; 13 | import org.tensorics.core.tensor.Tensor; 14 | 15 | /** 16 | * A class (to be extended or instantiated) that provides an access to the basic Boolean operations.
17 | * Note: Use through the delegation class {@link BooleanSupport} 18 | * 19 | * @author agorzaws 20 | */ 21 | public class TensorBooleanSupport { 22 | 23 | private final OptionRegistry optionRegistry; 24 | 25 | public TensorBooleanSupport(OptionRegistry optionRegistry) { 26 | this.optionRegistry = requireNonNull(optionRegistry); 27 | } 28 | 29 | public OngoingBooleanTensorOperation calcLogical(Tensor leftTensor) { 30 | return new OngoingBooleanTensorOperation(optionRegistry, leftTensor); 31 | } 32 | 33 | public OngoingDetection detectWhere(Tensor tensor) { 34 | return new OngoingDetection(tensor); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/booleans/lang/OngoingBooleanScalarOperation.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.booleans.lang; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import org.tensorics.core.booleans.operations.BooleanOperations; 6 | import org.tensorics.core.math.operations.BinaryOperation; 7 | 8 | public class OngoingBooleanScalarOperation { 9 | 10 | private final Boolean left; 11 | 12 | public OngoingBooleanScalarOperation(Boolean left) { 13 | this.left = requireNonNull(left, "left operator must not be null"); 14 | } 15 | 16 | public Boolean and(Boolean right) { 17 | return perform(BooleanOperations.and(), right); 18 | } 19 | 20 | public Boolean or(Boolean right) { 21 | return perform(BooleanOperations.or(), right); 22 | } 23 | 24 | public Boolean xor(Boolean right) { 25 | return perform(BooleanOperations.xor(), right); 26 | } 27 | 28 | public Boolean nand(Boolean right) { 29 | return perform(BooleanOperations.nand(), right); 30 | } 31 | 32 | private Boolean perform(BinaryOperation operation, Boolean right) { 33 | requireNonNull(right, "right operator must not be null"); 34 | return operation.perform(this.left, right); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/booleans/lang/OngoingDetection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.booleans.lang; 6 | 7 | import static java.util.Objects.requireNonNull; 8 | 9 | import java.util.Comparator; 10 | 11 | import org.tensorics.core.booleans.operations.TensorChangeDetectionOperation; 12 | import org.tensorics.core.tensor.Tensor; 13 | 14 | /** 15 | * @author agorzaws 16 | */ 17 | public class OngoingDetection { 18 | 19 | private final Tensor tensor; 20 | 21 | public OngoingDetection(Tensor tensor) { 22 | this.tensor = requireNonNull(tensor, "tensor must not be null"); 23 | } 24 | 25 | /** 26 | * Defines the direction of the tensor in which the searching of the changes will be performed. 27 | *

28 | * This class must implement {@link Comparable}. 29 | * 30 | * @param direction the dimension in which direction to search 31 | * @return 32 | */ 33 | public > Iterable changesAlong(Class direction) { 34 | return TensorChangeDetectionOperation.of(direction).apply(tensor); 35 | } 36 | 37 | public Iterable changesAlong(Class direction, Comparator comparator) { 38 | return TensorChangeDetectionOperation.of(direction, comparator).apply(tensor); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/booleans/operations/BooleanOperations.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.booleans.operations; 6 | 7 | import org.tensorics.core.math.operations.BinaryOperation; 8 | 9 | /** 10 | * Repository for logical operations 11 | *

    12 | *
  • AND
  • 13 | *
  • NAND
  • 14 | *
  • OR
  • 15 | *
  • XOR
  • 16 | *
17 | * 18 | * @author agorzaws 19 | */ 20 | public final class BooleanOperations { 21 | 22 | private static final BinaryOperation AND = (left, right) -> left && right; 23 | private static final BinaryOperation NAND = (left, right) -> !(left && right); 24 | private static final BinaryOperation OR = (left, right) -> left || right; 25 | private static final BinaryOperation XOR = (left, right) -> left ^ right; 26 | 27 | private BooleanOperations() { 28 | /* only static methods */ 29 | } 30 | 31 | public static BinaryOperation and() { 32 | return AND; 33 | } 34 | 35 | public static BinaryOperation nand() { 36 | return NAND; 37 | } 38 | 39 | public static BinaryOperation or() { 40 | return OR; 41 | } 42 | 43 | public static BinaryOperation xor() { 44 | return XOR; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/commons/options/Environment.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.commons.options; 24 | 25 | import org.tensorics.core.math.ExtendedField; 26 | 27 | /** 28 | * Encapsulates a field (on which all calculations are based) and a set of options, since the two are very commonly used 29 | * together and have to be passed on on many occasions. 30 | * 31 | * @author kfuchsbe 32 | * @param The type of the scalar values (elements of the field on which the operations are based) 33 | */ 34 | public interface Environment { 35 | 36 | ExtendedField field(); 37 | 38 | OptionRegistry options(); 39 | 40 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/commons/options/ManipulationOption.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.commons.options; 24 | 25 | /** 26 | * Marker interface for options which can be used to define the behaviour of iterable- and tensor operations. 27 | * 28 | * @author kfuchsbe 29 | */ 30 | public interface ManipulationOption extends Option { 31 | /* Just a marker interface for a special type of options. */ 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/commons/util/Named.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.commons.util; 6 | 7 | public interface Named { 8 | 9 | String name(); 10 | } 11 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/expressions/IsEqualToExpression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.expressions; 6 | 7 | import static java.lang.String.format; 8 | 9 | import org.tensorics.core.math.predicates.IsEqualTo; 10 | import org.tensorics.core.tree.domain.Expression; 11 | 12 | public class IsEqualToExpression extends BinaryPredicateExpression { 13 | private static final long serialVersionUID = 1L; 14 | 15 | public IsEqualToExpression(Expression left, Expression right) { 16 | super(new IsEqualTo(), left, right); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return format("%s is equal to %s", getLeft(), getRight()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/expressions/IsNotEqualExpression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.expressions; 6 | 7 | import static java.lang.String.format; 8 | 9 | import org.tensorics.core.math.predicates.IsNotEqualTo; 10 | import org.tensorics.core.tree.domain.Expression; 11 | 12 | public class IsNotEqualExpression extends BinaryPredicateExpression { 13 | private static final long serialVersionUID = 1L; 14 | 15 | public IsNotEqualExpression(Expression left, Expression right) { 16 | super(new IsNotEqualTo<>(), left, right); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return format("%s is not equal to %s", getLeft(), getRight()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/ContinuousFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2016, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.function; 23 | 24 | /** 25 | * This math function can return x values for (almost) any X values. The exact allowed x range depends on the 26 | * implementation. 27 | * 28 | * @author kfuchsbe 29 | * @param the type of the values in x-direction (Independent variable) 30 | * @param the type of the values in y-direction (Dependent variable) 31 | */ 32 | public interface ContinuousFunction extends MathFunction { 33 | 34 | // as an idea 35 | // Range allowedXRange(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/CoordinateToPositionFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.function; 24 | 25 | import java.util.function.Function; 26 | 27 | import org.tensorics.core.tensor.Position; 28 | 29 | public class CoordinateToPositionFunction implements Function { 30 | 31 | @Override 32 | public Position apply(C coordinate) { 33 | return Position.of(coordinate); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/DiscreteFunctionBuilder.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2016, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.function; 23 | 24 | /** 25 | * A builder for discrete functions. It provides methods to easily build {@link DiscreteFunction}s 26 | * 27 | * @author kfuchsbe 28 | * @param the type of the values along the X-axis 29 | * @param the type of the values along the Y-axis 30 | */ 31 | public interface DiscreteFunctionBuilder { 32 | 33 | DiscreteFunctionBuilder put(X key, Y value); 34 | 35 | DiscreteFunction build(); 36 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/IllegalDiscreteFunctionUsageException.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2016, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.function; 24 | 25 | /** 26 | * This exception is thrown, if a discrete function is used in a wrong way. 27 | * 28 | * @author agorzaws 29 | */ 30 | public class IllegalDiscreteFunctionUsageException extends RuntimeException { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | public IllegalDiscreteFunctionUsageException(String message) { 35 | super(message); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/InterpolatedFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2016, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.function; 23 | 24 | /** 25 | * Represents a math function that has been constructed by interpolating a discrete function so that it can return Y 26 | * values for any X values. The accuracy of the y values obtained is not defined by this contract. 27 | * 28 | * @author kfuchsbe, caguiler 29 | * @param the type of the values in x-direction (Independent variable) 30 | * @param the type of the values in y-direction (Dependent variable) 31 | */ 32 | public interface InterpolatedFunction extends ContinuousFunction, DiscreteFunction { 33 | /* Only marker at this point */ 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/function/MathFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2016, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.function; 23 | 24 | import java.util.function.Function; 25 | 26 | /** 27 | * The general function from X to Y 28 | * 29 | * @author kfuchsbe 30 | * @param the type of the values in x-direction (Independent variable) 31 | * @param the type of the values in y-direction (Dependent variable) 32 | */ 33 | public interface MathFunction extends Function { 34 | /* Marker interface */ 35 | } 36 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/FiniteArgumentFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * This interface represents a function that has a finite argument number in its signature. 9 | * 10 | * @see Func1 11 | * @see Func2 12 | * @see Func3 13 | * @see Func4 14 | * @see Func5 15 | * @see Func6 16 | * @see Func7 17 | * @see Func8 18 | * @see Func9 19 | * @param the return type of the function 20 | */ 21 | public interface FiniteArgumentFunction { 22 | 23 | /** 24 | * Transform this function to a {@link FuncN}, binding the arguments automatically. 25 | * 26 | * @return the {@link FuncN} representation of this function 27 | */ 28 | FuncN toFuncN(); 29 | 30 | /** 31 | * The number of arguments that the function accepts 32 | * 33 | * @return the number of arguments 34 | */ 35 | int numberOfArgs(); 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with one argument. 9 | * 10 | * @param the first argument type 11 | * @param the result type 12 | */ 13 | @FunctionalInterface 14 | public interface Func1 extends FiniteArgumentFunction { 15 | 16 | R apply(T t); 17 | 18 | @Override 19 | @SuppressWarnings("unchecked") 20 | default FuncN toFuncN() { 21 | return args -> apply((T) args[0]); 22 | } 23 | 24 | @Override 25 | default int numberOfArgs() { 26 | return 1; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with two arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the result type 13 | */ 14 | @FunctionalInterface 15 | public interface Func2 extends FiniteArgumentFunction { 16 | 17 | R apply(T1 t1, T2 t2); 18 | 19 | @Override 20 | @SuppressWarnings("unchecked") 21 | default FuncN toFuncN() { 22 | return args -> apply((T1) args[0], (T2) args[1]); 23 | } 24 | 25 | @Override 26 | default int numberOfArgs() { 27 | return 2; 28 | } 29 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func3.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with three arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the result type 14 | */ 15 | @FunctionalInterface 16 | public interface Func3 extends FiniteArgumentFunction { 17 | 18 | R apply(T1 t1, T2 t2, T3 t3); 19 | 20 | @Override 21 | @SuppressWarnings("unchecked") 22 | default FuncN toFuncN() { 23 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2]); 24 | } 25 | 26 | @Override 27 | default int numberOfArgs() { 28 | return 3; 29 | } 30 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func4.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with four arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the result type 15 | */ 16 | @FunctionalInterface 17 | public interface Func4 extends FiniteArgumentFunction { 18 | 19 | R apply(T1 t1, T2 t2, T3 t3, T4 t4); 20 | 21 | @Override 22 | @SuppressWarnings("unchecked") 23 | default FuncN toFuncN() { 24 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3]); 25 | } 26 | 27 | @Override 28 | default int numberOfArgs() { 29 | return 4; 30 | } 31 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func5.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with five arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the fifth argument type 15 | * @param the result type 16 | */ 17 | @FunctionalInterface 18 | public interface Func5 extends FiniteArgumentFunction { 19 | 20 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); 21 | 22 | @Override 23 | @SuppressWarnings("unchecked") 24 | default FuncN toFuncN() { 25 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3], (T5) args[4]); 26 | } 27 | 28 | @Override 29 | default int numberOfArgs() { 30 | return 5; 31 | } 32 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func6.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with six arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the fifth argument type 15 | * @param the sixth argument type 16 | * @param the result type 17 | */ 18 | @FunctionalInterface 19 | public interface Func6 extends FiniteArgumentFunction { 20 | 21 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); 22 | 23 | @Override 24 | @SuppressWarnings("unchecked") 25 | default FuncN toFuncN() { 26 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3], (T5) args[4], (T6) args[5]); 27 | } 28 | 29 | @Override 30 | default int numberOfArgs() { 31 | return 6; 32 | } 33 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func7.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with seven arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the fifth argument type 15 | * @param the sixth argument type 16 | * @param the seventh argument type 17 | * @param the result type 18 | */ 19 | @FunctionalInterface 20 | public interface Func7 extends FiniteArgumentFunction { 21 | 22 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); 23 | 24 | @Override 25 | @SuppressWarnings("unchecked") 26 | default FuncN toFuncN() { 27 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3], (T5) args[4], (T6) args[5], 28 | (T7) args[6]); 29 | } 30 | 31 | @Override 32 | default int numberOfArgs() { 33 | return 7; 34 | } 35 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func8.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with eight arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the fifth argument type 15 | * @param the sixth argument type 16 | * @param the seventh argument type 17 | * @param the eighth argument type 18 | * @param the result type 19 | */ 20 | @FunctionalInterface 21 | public interface Func8 extends FiniteArgumentFunction { 22 | 23 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); 24 | 25 | @Override 26 | @SuppressWarnings("unchecked") 27 | default FuncN toFuncN() { 28 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3], (T5) args[4], (T6) args[5], 29 | (T7) args[6], (T8) args[7]); 30 | } 31 | 32 | @Override 33 | default int numberOfArgs() { 34 | return 8; 35 | } 36 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/Func9.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a function with nine arguments. 9 | * 10 | * @param the first argument type 11 | * @param the second argument type 12 | * @param the third argument type 13 | * @param the fourth argument type 14 | * @param the fifth argument type 15 | * @param the sixth argument type 16 | * @param the seventh argument type 17 | * @param the eighth argument type 18 | * @param the ninth argument type 19 | * @param the result type 20 | */ 21 | @FunctionalInterface 22 | public interface Func9 extends FiniteArgumentFunction { 23 | 24 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); 25 | 26 | @Override 27 | @SuppressWarnings("unchecked") 28 | default FuncN toFuncN() { 29 | return args -> apply((T1) args[0], (T2) args[1], (T3) args[2], (T4) args[3], (T5) args[4], (T6) args[5], 30 | (T7) args[6], (T8) args[7], (T9) args[8]); 31 | } 32 | 33 | @Override 34 | default int numberOfArgs() { 35 | return 9; 36 | } 37 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/functional/FuncN.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.functional; 6 | 7 | /** 8 | * Represents a vector-argument function. 9 | * 10 | * @param the result type 11 | */ 12 | @FunctionalInterface 13 | public interface FuncN { 14 | R apply(Object... args); 15 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/iterable/operations/IterableOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.iterable.operations; 24 | 25 | import org.tensorics.core.commons.operations.Conversion; 26 | 27 | /** 28 | * An operation which takes one iterable as input and returns one value, corresponding to a super type of the iterable 29 | * elements. 30 | * 31 | * @author kfuchsbe 32 | * @param the type of the elements of the field, on which the operations are based on. 33 | */ 34 | public interface IterableOperation extends Conversion, T> { 35 | /* Nothing special here, inherits everything from ConversionOperation */ 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/iterable/operations/IterableStd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.iterable.operations; 6 | 7 | import static com.google.common.collect.Iterables.isEmpty; 8 | 9 | import org.tensorics.core.math.ExtendedField; 10 | import org.tensorics.core.scalar.lang.ScalarSupport; 11 | 12 | /** 13 | * An operation that takes and iterable of a certain type of values (for which a field has to be provided) and 14 | * calculates the standard deviation out of it. 15 | *

16 | * For the definition of the standard deviation, have a look at 17 | * wikipedia. 18 | * 19 | * @author caguiler 20 | * @param the type of the scalars (elements of the field on which the standard deviation will be based) 21 | */ 22 | public class IterableStd extends ScalarSupport implements IterableOperation { 23 | 24 | private final IterableVar iterableVar; 25 | private final ExtendedField field; 26 | 27 | public IterableStd(ExtendedField field) { 28 | super(field); 29 | this.field = field; 30 | this.iterableVar = new IterableVar<>(field); 31 | } 32 | 33 | @Override 34 | public V apply(Iterable values) { 35 | if (isEmpty(values)) { 36 | throw new IllegalArgumentException("standard deviation of empty value set is not possible."); 37 | } 38 | 39 | return calculate(iterableVar.apply(values)).root(field.two()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/lang/DoubleScript.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.lang; 23 | 24 | import org.tensorics.core.fields.doubles.Structures; 25 | 26 | /** 27 | * A convenience class designed for inheritance, already providing the doubles field in the constructor. 28 | * 29 | * @author kaifox 30 | * @param the type of the return value of the script 31 | */ 32 | public abstract class DoubleScript extends TensoricScript { 33 | private static final long serialVersionUID = 1L; 34 | 35 | public DoubleScript() { 36 | super(EnvironmentImpl.of(Structures.doubles(), ManipulationOptions.defaultOptions(Structures.doubles()))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/lang/OngoingBasicDeferredBinaryPredicate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.lang; 6 | 7 | import org.tensorics.core.expressions.BinaryPredicateExpression; 8 | import org.tensorics.core.math.predicates.IsEqualTo; 9 | import org.tensorics.core.math.predicates.IsNotEqualTo; 10 | import org.tensorics.core.tree.domain.Expression; 11 | import org.tensorics.core.tree.domain.ResolvedExpression; 12 | 13 | public class OngoingBasicDeferredBinaryPredicate { 14 | 15 | private final Expression left; 16 | 17 | public OngoingBasicDeferredBinaryPredicate(Expression left) { 18 | this.left = left; 19 | } 20 | 21 | public Expression isEqualTo(Expression right) { 22 | return new BinaryPredicateExpression<>(IsEqualTo.isEqualTo(), left, right); 23 | } 24 | 25 | public Expression isEqualTo(T right) { 26 | return isEqualTo(ResolvedExpression.of(right)); 27 | } 28 | 29 | public Expression isNotEqualTo(Expression right) { 30 | return new BinaryPredicateExpression<>(IsNotEqualTo.isNotEqualTo(), left, right); 31 | } 32 | 33 | public Expression isNotEqualTo(T right) { 34 | return isNotEqualTo(ResolvedExpression.of(right)); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/lang/QuantityDoubleSupport.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.lang; 24 | 25 | import org.tensorics.core.fields.doubles.Structures; 26 | import org.tensorics.core.quantity.lang.QuantitySupport; 27 | 28 | /** 29 | * This class is intended to be extended by classes who need to deal with quantities of double. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public class QuantityDoubleSupport extends QuantitySupport { 34 | 35 | protected QuantityDoubleSupport() { 36 | super(EnvironmentImpl.of(Structures.doubles(), ManipulationOptions.defaultOptions(Structures.doubles()))); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/lang/TensoricDoubleExpressionSupport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.lang; 6 | 7 | import org.tensorics.core.fields.doubles.Structures; 8 | 9 | public class TensoricDoubleExpressionSupport extends TensoricExpressionSupport { 10 | 11 | public TensoricDoubleExpressionSupport() { 12 | super(EnvironmentImpl.of(Structures.doubles(), ManipulationOptions.defaultOptions(Structures.doubles()))); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/BinaryFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.math.operations; 23 | 24 | public interface BinaryFunction { 25 | 26 | /** 27 | * Has to be implemented to perform the actual operation. The order of operands might be important or not, 28 | * depending, if the operation is commutative or not. 29 | * 30 | * @param left the left operand to be used in the operation 31 | * @param right the right operand to be used in the operation 32 | * @return the result of the operation 33 | */ 34 | R perform(T left, T right); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/BinaryOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.operations; 24 | 25 | /** 26 | * An operation for two values, which can be used in algebraic structures. 27 | * 28 | * @author kfuchsbe 29 | * @param the type of the elements of the algebraic structures. 30 | */ 31 | public interface BinaryOperation extends BinaryFunction { 32 | /* nothing special */ 33 | } 34 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/CommutativeAssociativeOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.operations; 24 | 25 | /** 26 | * A binary operation which guarantees both, associativity and commutativity. 27 | * 28 | * @author kfuchsbe 29 | * @param the type of elements on which the operation can be applied 30 | */ 31 | public interface CommutativeAssociativeOperation extends CommutativeOperation, AssociativeOperation { 32 | /* Only marks a dedicated type, to combine both interfaces */ 33 | } 34 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/CommutativeOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.operations; 24 | 25 | /** 26 | * Represents a binary operation on elements of a set, where the following condition is fullfilled: 27 | *

28 | * a o b = b o a, with 'a', 'b' being elements of the underlying set, 'o' being the operation. 29 | * 30 | * @author kfuchsbe 31 | * @param 32 | * @see http://en.wikipedia.org/wiki/Commutative_property 33 | * 34 | */ 35 | public interface CommutativeOperation extends BinaryOperation { 36 | /* only a marker */ 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/CreationOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.math.operations; 23 | 24 | /** 25 | * Represents an operation, which needs no arguments and creates an object of a certain type 26 | * 27 | * @author kaifox 28 | * @param the type of the object to be created by this operation 29 | */ 30 | public interface CreationOperation { 31 | 32 | /** 33 | * Performs the creation 34 | * 35 | * @return a newly created value of the specified type 36 | */ 37 | T perform(); 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/operations/UnaryOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.operations; 24 | 25 | /** 26 | * The general form of an unitary operation, to be used in algebraic structures. 27 | * 28 | * @author kfuchsbe 29 | * @param the type of values for which the unitary operation can be applied 30 | */ 31 | public interface UnaryOperation { 32 | 33 | /** 34 | * performs the operation on the given value 35 | * 36 | * @param value the input value, on which the operation shall be applied 37 | * @return the resulting value after the operation 38 | */ 39 | T perform(T value); 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/predicates/IsEqualTo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.math.predicates; 6 | 7 | public final class IsEqualTo implements BinaryPredicate { 8 | 9 | private static final IsEqualTo INSTANCE = new IsEqualTo<>(); 10 | 11 | @Override 12 | public Boolean perform(T left, T right) { 13 | return test(left, right); 14 | } 15 | 16 | @Override 17 | public boolean test(T left, T right) { 18 | return left.equals(right); 19 | } 20 | 21 | @SuppressWarnings("unchecked") 22 | public static final IsEqualTo isEqualTo() { 23 | return (IsEqualTo) INSTANCE; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/predicates/IsNotEqualTo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.math.predicates; 6 | 7 | public class IsNotEqualTo implements BinaryPredicate { 8 | 9 | private static final IsNotEqualTo INSTANCE = new IsNotEqualTo<>(); 10 | 11 | @Override 12 | public Boolean perform(T left, T right) { 13 | return test(left, right); 14 | } 15 | 16 | @Override 17 | public boolean test(T left, T right) { 18 | return !left.equals(right); 19 | } 20 | 21 | @SuppressWarnings("unchecked") 22 | public static final IsNotEqualTo isNotEqualTo() { 23 | return (IsNotEqualTo) INSTANCE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/structures/grouplike/AbelianGroup.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.structures.grouplike; 24 | 25 | /** 26 | * The algebraic structure of an abelian group (or commutative group). Thus the group operation is commutative and 27 | * associative. 28 | * 29 | * @author kfuchsbe 30 | * @param the type of the elements of the underlying set 31 | */ 32 | public interface AbelianGroup extends CommutativeMonoid, Group { 33 | /* All methods correctly defined in super interfaces */ 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/structures/grouplike/FiniteStructure.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.structures.grouplike; 24 | 25 | import java.util.Set; 26 | 27 | import org.tensorics.core.math.structures.Structure; 28 | 29 | /** 30 | * An algebraic structure, which has a finite number of elements. 31 | * 32 | * @author kfuchsbe 33 | * @param the type of the elements 34 | */ 35 | public interface FiniteStructure extends Structure { 36 | 37 | /** 38 | * Retrieves all the elements of the structure. 39 | * 40 | * @return all the elements of the algebraic structure. 41 | */ 42 | Set elements(); 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/structures/grouplike/Magma.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.structures.grouplike; 24 | 25 | /** 26 | * The algebraic structure of a Magma (or also called groupoid). It has the following properties: 27 | *

    28 | *
  • a set (M) of elements of type T
  • 29 | *
  • one binary operation M x M : M
  • 30 | *
31 | * 32 | * @param 33 | * @see http://en.wikipedia.org/wiki/Magma_(algebra) 34 | */ 35 | public interface Magma extends GrouplikeStructure { 36 | /* everything already defined in super interfaces */ 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/math/structures/ringlike/Ring.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.math.structures.ringlike; 24 | 25 | import org.tensorics.core.math.structures.grouplike.AbelianGroup; 26 | 27 | /** 28 | * A ringlike algebraic structure, whose additive monoid is an abelian group. 29 | * 30 | * @author kfuchsbe 31 | * @param the type of the elements of the underlying set 32 | */ 33 | public interface Ring extends Semiring { 34 | 35 | @Override 36 | AbelianGroup additionStructure(); 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/quantity/ErronousValue.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.quantity; 24 | 25 | import java.io.Serializable; 26 | 27 | import com.google.common.base.Optional; 28 | 29 | /** 30 | * A scalar value that additionally holds an error. The error type is the same as the value type. 31 | * 32 | * @author kfuchsbe 33 | * @param the type of the value of the scalar and therefore also the one of the error. 34 | */ 35 | public interface ErronousValue extends Serializable { 36 | 37 | V value(); 38 | 39 | /** 40 | * Retrieve the error of the scalar 41 | * 42 | * @return the error 43 | */ 44 | Optional error(); 45 | } 46 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/quantity/Quantified.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.quantity; 24 | 25 | import org.tensorics.core.units.Unit; 26 | 27 | /** 28 | * Any object that has a base. 29 | * 30 | * @author kfuchsbe 31 | */ 32 | public interface Quantified { 33 | 34 | /** 35 | * Retrieves the base of the entity 36 | * 37 | * @return the base of the quantified entity. 38 | */ 39 | Unit unit(); 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/quantity/ValidityAware.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.quantity; 24 | 25 | /** 26 | * Marks an instance that has a flag, if the content of the object is valid or not. The meaning of 'validity' depends on 27 | * the context. In the context of tensorics, the validity flag is usually used for flagging values of tensors. 28 | * 29 | * @author kfuchsbe 30 | */ 31 | public interface ValidityAware { 32 | 33 | /** 34 | * Retrieves the validity flag of the object. 35 | * 36 | * @return {@code true} if the content is valid, {@code false} if it is not. 37 | */ 38 | Boolean validity(); 39 | } 40 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/quantity/operations/QuantityAbsoluteValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.quantity.operations; 6 | 7 | import org.tensorics.core.lang.Tensorics; 8 | import org.tensorics.core.quantity.QuantifiedValue; 9 | import org.tensorics.core.quantity.options.QuantityEnvironment; 10 | 11 | public class QuantityAbsoluteValue extends QuantityUnaryOperation { 12 | private static final long serialVersionUID = 1L; 13 | 14 | public QuantityAbsoluteValue(QuantityEnvironment environment) { 15 | super(environment); 16 | } 17 | 18 | @Override 19 | public QuantifiedValue perform(QuantifiedValue scalar) { 20 | S newValue = environment().field().absoluteValue().perform(scalar.value()); 21 | return Tensorics.quantityOf(newValue, scalar.unit()).withError(scalar.error()).withValidity(scalar.validity()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/quantity/options/ConfidenceLevel.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.quantity.options; 24 | 25 | import org.tensorics.core.commons.options.ManipulationOption; 26 | 27 | /** 28 | * {@link ManipulationOption} to allow setting a confidence level for statistical tests. 29 | * 30 | * @author mihostet 31 | * @param 32 | */ 33 | public interface ConfidenceLevel extends ManipulationOption { 34 | 35 | S confidenceLevel(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/reduction/InterpolatedSlicing.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.reduction; 6 | 7 | import java.util.Map; 8 | 9 | import org.tensorics.core.lang.Tensorics; 10 | import org.tensorics.core.tensor.Position; 11 | import org.tensorics.core.tensor.Tensor; 12 | 13 | /** 14 | * The extended slicing strategy that involves the possibility to interpolate over the specified, comparable coordinate 15 | * 16 | * @author agorzaws 17 | * @param the type of the hold values 18 | * @param the type of the interpolation direction, must be Comparable 19 | */ 20 | public class InterpolatedSlicing extends Slicing { 21 | 22 | private final InterpolationStrategy strategy; 23 | private final Tensor tensor; 24 | 25 | public InterpolatedSlicing(C slicePosition, InterpolationStrategy strategy, Tensor tensor) { 26 | super(slicePosition); 27 | this.strategy = strategy; 28 | this.tensor = tensor; 29 | } 30 | 31 | @Override 32 | public E reduce(Map inputValues, Position position) { 33 | if (inputValues.get(slicePosition) == null) { 34 | Tensor extractedToInterpolate = Tensorics.from(tensor).extract(position); 35 | return strategy.getInterpolatedValue(extractedToInterpolate, slicePosition); 36 | } else { 37 | return inputValues.get(slicePosition); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/reduction/InterpolationStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.reduction; 6 | 7 | import org.tensorics.core.tensor.Tensor; 8 | 9 | /** 10 | * The interface for the interpolation strategy in the tensors. 11 | * 12 | * @author agorzaws 13 | * @param type of the coordinate, must extends {@link Comparable} 14 | * @param type of the values in the {@link Tensor} 15 | */ 16 | public interface InterpolationStrategy { 17 | 18 | /** 19 | * Returns interpolated value for coordinate C. 20 | * 21 | * @param tensorWithTheOnlyOneCoordinateOfC the tensor where only C coordinates are kept 22 | * @param coordineteToInterpolate 23 | * @return the interpolated value 24 | */ 25 | V getInterpolatedValue(Tensor tensorWithTheOnlyOneCoordinateOfC, C coordineteToInterpolate); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/reduction/ToFunctions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.reduction; 6 | 7 | import java.util.Map; 8 | 9 | import org.tensorics.core.function.DiscreteFunction; 10 | import org.tensorics.core.function.MapBackedDiscreteFunction; 11 | import org.tensorics.core.tensor.Position; 12 | 13 | /** 14 | * A reduction strategy which reduces all elements of dimension {@code } by transforming them into a 15 | * {@link DiscreteFunction} s from {@code } to {@code } 16 | * 17 | * @author kfuchsbe, caguiler 18 | * @param the type of the values along the X-axis, the type of coordinate (aka 'the dimension') do be reduced 19 | * @param the type of the tensor elements and also the type of the values along the Y-axis 20 | */ 21 | public final class ToFunctions implements ReductionStrategy> { 22 | @Override 23 | public DiscreteFunction reduce(Map inputValues, Position position) { 24 | return MapBackedDiscreteFunction.fromMap(inputValues); 25 | } 26 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/options/AbstractExceptionHandlingStrategy.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.resolve.options; 24 | 25 | /** 26 | * @author kfuchsbe 27 | */ 28 | public abstract class AbstractExceptionHandlingStrategy implements ExceptionHandlingStrategy { 29 | 30 | @Override 31 | public Class getMarkerInterface() { 32 | return ExceptionHandlingStrategy.class; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/options/ExceptionHandlingStrategy.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.resolve.options; 24 | 25 | import org.tensorics.core.resolve.domain.ExceptionHandlingRequest; 26 | 27 | /** 28 | * A strategy which is used in the dispatcher to decide how exceptions are handled. Possible implementations would 29 | * either be to handle them in some upper nodes or forward them un-filtered to the client application. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public interface ExceptionHandlingStrategy extends ResolvingOption { 34 | 35 | void handleWithRootNodeFailingNodeException(ExceptionHandlingRequest parameterObject); 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/options/ResolvingOption.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.resolve.options; 24 | 25 | import org.tensorics.core.commons.options.Option; 26 | 27 | /** 28 | * The marker interface which is used as upper bound for options that are related to the resolving engines. This options 29 | * might include, for example, strategies for selecting resolvers and handling exceptions. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public interface ResolvingOption extends Option { 34 | /* Only marker */ 35 | } 36 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/resolvers/FunctionalExpressionResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.resolve.resolvers; 6 | 7 | import org.tensorics.core.functional.expressions.FunctionalExpression; 8 | import org.tensorics.core.tree.domain.ResolvingContext; 9 | 10 | public class FunctionalExpressionResolver extends AbstractResolver> { 11 | 12 | @Override 13 | public boolean canResolve(FunctionalExpression expression, ResolvingContext context) { 14 | return Resolvers.contextResolvesAll(expression.getChildren(), context); 15 | } 16 | 17 | @Override 18 | public R resolve(FunctionalExpression expression, ResolvingContext context) { 19 | Object[] arguments = expression.getChildren().stream().map(child -> context.resolvedValueOf(child)).toArray(); 20 | return expression.function().apply(arguments); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/resolvers/IterableExpressionToIterableResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.resolve.resolvers; 6 | 7 | import static java.util.stream.Collectors.toList; 8 | 9 | import org.tensorics.core.iterable.expressions.IterableExpressionToIterable; 10 | import org.tensorics.core.tree.domain.ResolvingContext; 11 | 12 | public class IterableExpressionToIterableResolver 13 | extends AbstractResolver, IterableExpressionToIterable> { 14 | 15 | @Override 16 | public boolean canResolve(IterableExpressionToIterable expression, ResolvingContext context) { 17 | return Resolvers.contextResolvesAll(expression.getChildren(), context); 18 | } 19 | 20 | @Override 21 | public Iterable resolve(IterableExpressionToIterable expression, ResolvingContext context) { 22 | return expression.getChildren().stream().map(context::resolvedValueOf).collect(toList()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/resolvers/IterableResolvingExpressionResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.resolve.resolvers; 6 | 7 | import java.util.stream.Collectors; 8 | 9 | import org.tensorics.core.expressions.IterableResolvingExpression; 10 | import org.tensorics.core.tree.domain.ResolvingContext; 11 | 12 | /** 13 | * Resolver for a {@link IterableResolvingExpression}. 14 | * 15 | * @see IterableResolvingExpression 16 | * @author acalia, caguiler, kfuchsberger 17 | * @param 18 | */ 19 | public class IterableResolvingExpressionResolver 20 | extends AbstractResolver, IterableResolvingExpression> { 21 | 22 | @Override 23 | public boolean canResolve(IterableResolvingExpression expression, ResolvingContext context) { 24 | return Resolvers.contextResolvesAll(expression.expressions(), context); 25 | } 26 | 27 | @Override 28 | public Iterable resolve(IterableResolvingExpression expression, ResolvingContext context) { 29 | return expression.expressions().stream().map(context::resolvedValueOf).collect(Collectors.toList()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/resolvers/PickResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.resolve.resolvers; 6 | 7 | import org.tensorics.core.iterable.expressions.PickExpression; 8 | import org.tensorics.core.iterable.expressions.PickExpression.Mode; 9 | import org.tensorics.core.tree.domain.ResolvingContext; 10 | 11 | /** 12 | * Resolver for {@link PickExpression} expression. 13 | * 14 | * @see PickExpression 15 | * @author acalia 16 | * @param the type of the data to pick 17 | */ 18 | public class PickResolver extends AbstractResolver> { 19 | 20 | @Override 21 | public boolean canResolve(PickExpression expression, ResolvingContext context) { 22 | return context.resolves(expression.iterableExpression()); 23 | } 24 | 25 | @Override 26 | public T resolve(PickExpression expression, ResolvingContext context) { 27 | Iterable iterable = context.resolvedValueOf(expression.iterableExpression()); 28 | Mode mode = expression.mode(); 29 | int offset = expression.offset(); 30 | 31 | return mode.pick(iterable, offset); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/resolve/resolvers/PredicateConditionResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.resolve.resolvers; 6 | 7 | import java.util.function.Predicate; 8 | 9 | import org.tensorics.core.expressions.PredicateExpression; 10 | import org.tensorics.core.tree.domain.ResolvingContext; 11 | 12 | public class PredicateConditionResolver extends AbstractResolver> { 13 | 14 | @Override 15 | public boolean canResolve(PredicateExpression expression, ResolvingContext context) { 16 | return Resolvers.contextResolvesAll(expression.getChildren(), context); 17 | } 18 | 19 | @Override 20 | public Boolean resolve(PredicateExpression assertion, ResolvingContext context) { 21 | T source = context.resolvedValueOf(assertion.source()); 22 | Predicate predicate = context.resolvedValueOf(assertion.predicate()); 23 | return predicate.test(source); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/Mappable.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensor; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Allows its implementors to provide a method to view the tensor as a map from position to values. This interface is 7 | * intended to be used by utility methods in order to avoid unnecessary calls. 8 | * 9 | * @author kaifox 10 | * @param the type of the values of the tensors 11 | */ 12 | public interface Mappable { 13 | 14 | /** 15 | * By implementing this method, a tensor can provide an efficient way to convert the tensor to a map from position 16 | * to values. Implementing instances must follow the following contract: 17 | *
    18 | *
  • this method must not return {@code null} 19 | *
  • It is recommended to return either a copy or an immutable map. Despite clients are not supposed to manipulate 20 | * the returned maps, it cannot be guaranteed and this could lead to unexpected results. 21 | *
22 | * Usually, clients will not use this method directly, but should use 23 | * {@link org.tensorics.core.tensor.operations.TensorInternals#mapFrom(Tensor)} (internal clients) or 24 | * {@link org.tensorics.core.lang.Tensorics#mapFrom(Tensor)} (external clients) 25 | * 26 | * @see org.tensorics.core.tensor.operations.TensorInternals#mapFrom(Tensor) 27 | * @see org.tensorics.core.lang.Tensorics#mapFrom(Tensor) 28 | * @return a (preferrably immutable) map representing the content of the tensor 29 | */ 30 | public Map asMap(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/MappableTensor.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensor; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Enhances the tensor interface by a method to view the tensor as a map from position to values. This interface is 7 | * intended to be used by utility methods in order to avoid unnecessary calls. 8 | * 9 | * @author kaifox 10 | * @param the type of the values of the tensors 11 | */ 12 | public interface MappableTensor extends Tensor { 13 | 14 | /** 15 | * By implementing this method, a tensor can provide an efficient way to convert the tensor to a map from position 16 | * to values. Implementing instances must follow the following contract: 17 | *
    18 | *
  • this method must not return {@code null} 19 | *
  • It is recommended to return either a copy or an immutable map. Despite clients are not supposed to manipulate 20 | * the returned maps, it cannot be guaranteed and this could lead to unexpected results. 21 | *
22 | * Usually, clients will not use this method directly, but should use 23 | * {@link org.tensorics.core.tensor.operations.TensorInternals#mapFrom(Tensor)} (internal clients) or 24 | * {@link org.tensorics.core.lang.Tensorics#mapFrom(Tensor)} (external clients) 25 | * 26 | * @see org.tensorics.core.tensor.operations.TensorInternals#mapFrom(Tensor) 27 | * @see org.tensorics.core.lang.Tensorics#mapFrom(Tensor) 28 | * @return a (preferrably immutable) map representing the content of the tensor 29 | */ 30 | public Map asMap(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/Scalar.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensor; 2 | 3 | /** 4 | * The specialization of a tensor with zero dimensions and exactly one value. In detail, implementations have to 5 | * guarantee the following: 6 | *
    7 | *
  • Has exactly one value (not zero, no more) 8 | *
  • has always zero dimensions 9 | *
  • The only valid position to query is the 'empty' position 10 | *
11 | * Still, a scalar can have a context. Indeed, this is a very valuable property in the framework of tensorics. 12 | *

13 | * NOTE: It might sometimes be confusing, that in mathematics and commons language the term 'scalar' is sometimes used 14 | * interchangible for a zero-dimensional tensor (what this class represents) and the values/entries of the tensors 15 | * itself. Therefore, we will denote the values of a tensor (scalar) as 'values' and zero-dimensional tensors as 16 | * scalars. 17 | * 18 | * @author kaifox 19 | * @param the type of the value of the scalar 20 | */ 21 | public interface Scalar extends Tensor { 22 | 23 | /** 24 | * Has to retrieve the value of the scalar. In implementations, this has to be equivalent to calling 25 | * {@link #get(Object...)} with an empty array of coordinates and with calling {@link #get(Position)} with an empty 26 | * position. 27 | * 28 | * @return the internal value of the scalar 29 | */ 30 | public V value(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/TensorView.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.tensor; 23 | 24 | /** 25 | * Marks a tensor, which is a view on one or more other tensor(s). The main purpose of this interface is currently to 26 | * make the fact of 'viewing' more explicit and let the user reflect on the consequences. (I.g. A tensor is not equal to 27 | * its own view.) 28 | * 29 | * @author kaifox 30 | * @param the type of the values of the tensor 31 | */ 32 | public interface TensorView extends Tensor { 33 | /* Currently only a marker interface */ 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/doc-files/base-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorics/tensorics-core/18b27795070fb8a3e5b50ecb733b010de53e81f8/src/java/org/tensorics/core/tensor/doc-files/base-hierarchy.png -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/doc-files/base-hierarchy.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/lang/OngoingResamplingStart.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensor.lang; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.Comparator; 6 | 7 | import org.tensorics.core.tensor.Tensor; 8 | import org.tensorics.core.tensor.resample.impl.RepeatingResampler; 9 | 10 | public class OngoingResamplingStart { 11 | 12 | private final Tensor tensor; 13 | 14 | public OngoingResamplingStart(Tensor tensor) { 15 | this.tensor = requireNonNull(tensor, "tensor must not be null"); 16 | } 17 | 18 | public OngoingResampling repeat(Class dimension, Comparator dimensionComparator) { 19 | return OngoingResampling.of(tensor, dimension, new RepeatingResampler<>(dimensionComparator)); 20 | } 21 | 22 | public > OngoingResampling repeat(Class dimension) { 23 | return repeat(dimension, Comparator.naturalOrder()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/lang/OngoingTensorReduction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.tensor.lang; 6 | 7 | import org.tensorics.core.reduction.ReductionStrategy; 8 | import org.tensorics.core.tensor.Tensor; 9 | 10 | public class OngoingTensorReduction { 11 | 12 | public Tensor by(ReductionStrategy strategy) { 13 | return reduceBy(strategy); 14 | } 15 | 16 | protected Tensor reduceBy(ReductionStrategy strategy) { 17 | return null;// return new TensorReduction<>(dimension, strategy).apply(tensor); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/options/ContextPropagationStrategy.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.tensor.options; 23 | 24 | import org.tensorics.core.commons.options.ManipulationOption; 25 | import org.tensorics.core.tensor.Position; 26 | 27 | /** 28 | * Defines how the context is propagated during a binary tensor operation. 29 | * 30 | * @author kfuchsbe 31 | */ 32 | public interface ContextPropagationStrategy extends ManipulationOption { 33 | 34 | Position contextForLeftRight(Position leftContext, Position rightContext); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | /** 6 | * This package contains the base classes for tensoric elements. There are in general two aspects taken into account by 7 | * this hierarchy: 8 | *

    9 | *
  1. Deferrence: A tensoric can either be a real object containing data or it can be 'deferred', meaning that 10 | * is simply a placeholder for the real object, which will be determined later. 11 | *
  2. Tensoric base types: The base type for all real data-holding objects is the Tensor. A special version of 12 | * it is a scalar, which has zero dimensions (order, rank). A special treatment is sometimes required for the elements 13 | * of the tensors themselves: These can be java objects of any type. However, if calculations have to be performed by 14 | * them, than a mathematical environment is required for them. 15 | *
16 | * An overview of the actual types is depicted in the following diagram: 17 | *

18 | * 19 | */ 20 | package org.tensorics.core.tensor; 21 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensor/specific/TooLargeForArrayException.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.tensor.specific; 23 | 24 | /** 25 | * This exception will be thrown if an array of a too large size would be required to store all the tensor values. 26 | * 27 | * @author kfuchsbe 28 | */ 29 | public class TooLargeForArrayException extends RuntimeException { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | public TooLargeForArrayException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/Tensorbacked.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked; 24 | 25 | import org.tensorics.core.tensor.Position; 26 | import org.tensorics.core.tensor.Tensor; 27 | import org.tensorics.core.tensor.Tensoric; 28 | 29 | /** 30 | * Interface for any object that will support Tensors and it will be able to transform itself into a tensor ie. for 31 | * mathematics calculations. 32 | * 33 | * @param Type of the tensor which backs this object. 34 | * @author agorzaws 35 | */ 36 | public interface Tensorbacked { 37 | 38 | /** 39 | * @return a {@link Tensor} for given types. 40 | */ 41 | Tensor tensor(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/DimtypedTensorbacked.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | import org.tensorics.core.tensorbacked.Tensorbacked; 4 | 5 | public interface DimtypedTensorbacked extends Tensorbacked { 6 | /* Marker interface to constrain method arguments*/ 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/DimtypedTensorbackedBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | import org.tensorics.core.tensor.Position; 4 | import org.tensorics.core.tensor.Tensor; 5 | import org.tensorics.core.tensorbacked.Tensorbacked; 6 | import org.tensorics.core.tensorbacked.TensorbackedBuilder; 7 | 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | public interface DimtypedTensorbackedBuilder, B extends DimtypedTensorbackedBuilder> extends TensorbackedBuilder { 12 | 13 | @Override 14 | B context(Position context); 15 | 16 | @Override 17 | B context(Object... coordinates); 18 | 19 | @Override 20 | B putAll(Tensor tensor); 21 | 22 | @Override 23 | B putAll(Position position, Tensor tensor); 24 | 25 | @Override 26 | B putAll(Position position, Tensorbacked tensorbacked); 27 | 28 | @Override 29 | B putAll(TB tensorBacked); 30 | 31 | @Override 32 | B put(Position position, V value); 33 | 34 | @Override 35 | B putAll(Set> entries); 36 | 37 | @Override 38 | B put(Map.Entry entry); 39 | 40 | @Override 41 | B remove(Position position); 42 | 43 | @Override 44 | B putAll(Map newEntries); 45 | 46 | @Override 47 | B putAll(Position position, Map map); 48 | 49 | @Override 50 | TB build(); 51 | } 52 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked1d.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked1d extends DimtypedTensorbacked { 4 | 5 | default V get(C1 c1) { 6 | return tensor().get(c1); 7 | } 8 | 9 | default boolean contains(C1 c1) { 10 | return tensor().contains(c1); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked1dBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked1dBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | Tensorbacked1dBuilder put(C1 c1, V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked2d.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked2d extends DimtypedTensorbacked { 4 | 5 | default V get(C1 c1, C2 c2) { 6 | return tensor().get(c1, c2); 7 | } 8 | 9 | 10 | default boolean contains(C1 c1, C2 c2) { 11 | return tensor().contains(c1, c2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked2dBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked2dBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | Tensorbacked2dBuilder put(C1 c1, C2 c2, V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked3d.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked3d extends DimtypedTensorbacked { 4 | 5 | default V get(C1 c1, C2 c2, C3 c3) { 6 | return tensor().get(c1, c2, c3); 7 | } 8 | 9 | default boolean contains(C1 c1, C2 c2, C3 c3) { 10 | return tensor().contains(c1, c2, c3); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked3dBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked3dBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | Tensorbacked3dBuilder put(C1 c1, C2 c2, C3 c3, V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked4d.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked4d extends DimtypedTensorbacked { 4 | 5 | default V get(C1 c1, C2 c2, C3 c3, C4 c4) { 6 | return tensor().get(c1, c2, c3, c4); 7 | } 8 | 9 | default boolean contains(C1 c1, C2 c2, C3 c3, C4 c4) { 10 | return tensor().contains(c1, c2, c3, c4); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked4dBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked4dBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | Tensorbacked4dBuilder put(C1 c1, C2 c2, C3 c3, C4 c4, V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked5d.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked5d extends DimtypedTensorbacked { 4 | 5 | default V get(C1 c1, C2 c2, C3 c3, C4 c4, C5 c5) { 6 | return tensor().get(c1, c2, c3, c4, c5); 7 | } 8 | 9 | default boolean contains(C1 c1, C2 c2, C3 c3, C4 c4, C5 c5) { 10 | return tensor().contains(c1, c2, c3, c4, c5); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/Tensorbacked5dBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface Tensorbacked5dBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | Tensorbacked5dBuilder put(C1 c1, C2 c2, C3 c3, C4 c4, C5 c5, V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/TensorbackedScalar.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface TensorbackedScalar extends DimtypedTensorbacked { 4 | 5 | default V get() { 6 | return tensor().get(); 7 | } 8 | 9 | default V value() { 10 | return get(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/dimtyped/TensorbackedScalarBuilder.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | public interface TensorbackedScalarBuilder> extends DimtypedTensorbackedBuilder> { 4 | 5 | TensorbackedScalarBuilder put(V v); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/operations/QuantifiedTensorBackedUnaryOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.operations; 24 | 25 | import org.tensorics.core.math.operations.UnaryOperation; 26 | import org.tensorics.core.quantity.QuantifiedValue; 27 | import org.tensorics.core.tensorbacked.Tensorbacked; 28 | 29 | /** 30 | * This interface defines the type of the operation for {@link Tensorbacked} objects. 31 | * 32 | * @author agorzaws 33 | * @param 34 | * @param 35 | */ 36 | public interface QuantifiedTensorBackedUnaryOperation>> 37 | extends UnaryOperation { 38 | /* Only a marker */ 39 | } 40 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tensorbacked/operations/TensorBackedUnaryOperation.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.operations; 24 | 25 | import org.tensorics.core.math.operations.UnaryOperation; 26 | import org.tensorics.core.tensorbacked.Tensorbacked; 27 | 28 | /** 29 | * This interface defines the type of the operation for {@link Tensorbacked} objects. 30 | * 31 | * @author agorzaws 32 | * @param 33 | * @param 34 | */ 35 | public interface TensorBackedUnaryOperation> extends UnaryOperation { 36 | /* Only a marker */ 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/testing/TensoricTests.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.testing; 24 | 25 | /** 26 | * Static methods for base tests involving tensorics objects. 27 | * 28 | * @author kfuchsbe 29 | */ 30 | public class TensoricTests { 31 | /* nothing yet */ 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/testing/hamcrest/TensoricsMatchers.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.testing.hamcrest; 24 | 25 | import org.hamcrest.Matcher; 26 | import org.tensorics.core.tensor.Tensor; 27 | 28 | /** 29 | * Provides factory methods for matchers for tensoric objects. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public final class TensoricsMatchers { 34 | 35 | private TensoricsMatchers() { 36 | /* Only static methods */ 37 | } 38 | 39 | public static Matcher> allElementsEqualTo(V value) { 40 | return AllElementsEqualTo.allElementsEqualTo(value); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/domain/ExceptionHandlingNode.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.domain; 24 | 25 | /** 26 | * Interface for node that can ultimately handle exception propagation from bottom nodes. 27 | * 28 | * @author agorzaws 29 | * @param type of handled return type. 30 | */ 31 | public interface ExceptionHandlingNode extends Expression { 32 | 33 | /** 34 | * @param exception to handle, usually comes from bottom nodes 35 | * @return a resolved value that shall be used instead of the respective node. 36 | */ 37 | R handle(Exception exception); 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/domain/Node.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.domain; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * A marker interface for any node in the instruction tree, which later will be processed by a tree walker. 29 | * 30 | * @author amoscate 31 | */ 32 | public interface Node { 33 | 34 | /** 35 | * Has to return the children of the node. This must never return {@code null} 36 | * 37 | * @return a list containing all the children of the node 38 | */ 39 | List getChildren(); 40 | 41 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/BottomNodeCallback.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | import org.tensorics.core.tree.domain.Node; 26 | 27 | /** 28 | * A callback for the tree walker, which will be called as soon as a bottom node (a node without any children) is 29 | * reached. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public interface BottomNodeCallback extends NodeCallback { 34 | 35 | /** 36 | * This method will be called as soon as the bottom node of a tree is reached. 37 | * 38 | * @param node the bottom node 39 | */ 40 | void onBottom(Node node); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/EveryNodeCallback.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | import org.tensorics.core.tree.domain.Node; 26 | 27 | /** 28 | * A callback for an {@link TreeWalker} that allows to get notified on every visite of a node in the tree. 29 | * 30 | * @author kfuchsbe 31 | */ 32 | public interface EveryNodeCallback extends NodeCallback { 33 | 34 | /** 35 | * This method will be called by the tree walker, when a node is visited. 36 | * 37 | * @param node the node which is visited 38 | */ 39 | void onEvery(Node node); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/LoopDetectedException.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | /** 26 | * This exception will be thrown by the tree walker, if a loop in the tree might be found. This most probalbly indicates 27 | * an ill-defined tree and might be due to a programming error. 28 | * 29 | * @author kfuchsbe 30 | */ 31 | public class LoopDetectedException extends RuntimeException { 32 | private static final long serialVersionUID = 1L; 33 | 34 | public LoopDetectedException(String message) { 35 | super(message); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/NoMatchingNodeFoundException.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | package org.tensorics.core.tree.walking; 23 | 24 | /** 25 | * Might be thrown, if the tree is searched for a certain type (for example, a node that can handle an exception) of 26 | * node and no corresponding node can be found. 27 | * 28 | * @author kfuchsbe 29 | */ 30 | public class NoMatchingNodeFoundException extends RuntimeException { 31 | private static final long serialVersionUID = 1L; 32 | 33 | public NoMatchingNodeFoundException(String message) { 34 | super(message); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/NodeCallback.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | /** 26 | * Marks objects that can be passed into a tree walker, and which are called at a certain stages of the 27 | * walking-procedure. The exact stage, when the callbacks are called, are defined by the sub types of this interface. 28 | * 29 | * @author kfuchsbe 30 | */ 31 | public interface NodeCallback { 32 | /* Only a marker interface */ 33 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/SkipStepDownCallback.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | import org.tensorics.core.tree.domain.Node; 26 | 27 | /** 28 | * If this callback is passed into the tree walker, then it will be called any time, the walker moves from a parent node 29 | * to a child node. The instance of the callback can decide, if the walker shall continue to walk down to the child 30 | * node, or not. 31 | * 32 | * @author kfuchsbe 33 | */ 34 | public interface SkipStepDownCallback extends NodeCallback { 35 | 36 | boolean shallSkipStepDownFromParentToChild(Node parentNode, Node childNode); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/tree/walking/StepUpCallback.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.walking; 24 | 25 | import org.tensorics.core.tree.domain.Node; 26 | 27 | /** 28 | * If a callback of this type is passed to a tree walker, then its single method is called each time the walker passes 29 | * from a child node to its parent node. 30 | * 31 | * @author kfuchsbe 32 | */ 33 | public interface StepUpCallback extends NodeCallback { 34 | 35 | void onStepUpFromChildToParent(Node child, Node parent); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/units/Unit.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.units; 24 | 25 | import java.io.Serializable; 26 | 27 | /** 28 | * Represents a physical base in its most generic form. 29 | * 30 | * @author kfuchsbe 31 | */ 32 | public interface Unit extends Serializable { 33 | /* 34 | * At the moment we do not expose anything here, since the only implementation is backed by JScience and we anyway 35 | * have to cast to the implementation for base-procesessing (which *should* be properly encapsulated). At some point 36 | * we will expose here useful methods (e.g. the physical dimension?). Therefore this should stay. 37 | */ 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/JavaVersions.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.util; 2 | 3 | /** 4 | * Contains utility methods related to java versions 5 | */ 6 | public final class JavaVersions { 7 | 8 | private JavaVersions() { 9 | throw new UnsupportedOperationException("only static methods"); 10 | } 11 | 12 | /** 13 | * Determines if the actual running jvm is at least java 11 14 | * 15 | * @return true if it is java 11 or higher, false otherwise 16 | */ 17 | public static boolean isAtLeastJava11() { 18 | return "11".compareTo(System.getProperty("java.version")) <= 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/MoreMultisets.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.util; 2 | 3 | import static com.google.common.collect.Multisets.difference; 4 | 5 | import com.google.common.collect.ImmutableMultiset; 6 | import com.google.common.collect.Multiset; 7 | 8 | public class MoreMultisets { 9 | 10 | private MoreMultisets() { 11 | /* only static methods */ 12 | } 13 | 14 | public static boolean containsNonUniqueElements(Multiset dimensions) { 15 | return dimensions.size() > dimensions.elementSet().size(); 16 | } 17 | 18 | public static Multiset nonUniqueElementsOf(Multiset dimensions) { 19 | return difference(dimensions, ImmutableMultiset.copyOf(dimensions.elementSet())); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/chains/AbstractRecursiveRepresenter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | import java.util.function.Function; 8 | 9 | public abstract class AbstractRecursiveRepresenter { 10 | 11 | /* This has to be package private, because it is injected by the framework */ 12 | Function recursion; 13 | 14 | protected R recurse(Object object) { 15 | return this.recursion.apply(object); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/chains/BranchChainBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | final class BranchChainBuilder extends AbstractChainBuilder, BranchChainBuilder> { 8 | 9 | @Override 10 | Branch build() { 11 | return new Branch<>(this); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/chains/Chain.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | import java.util.function.BiFunction; 8 | import java.util.function.Function; 9 | 10 | public final class Chain implements Function { 11 | 12 | private final ImmutableRecursion delegate; 13 | 14 | public Chain(BiFunction, R> delegate, Function endRecursionFunction, 15 | int endRecursionDepth) { 16 | this.delegate = ImmutableRecursion.delegatingTo(delegate).endingRecursionWith(endRecursionFunction) 17 | .endRecursionAtDepth(endRecursionDepth); 18 | } 19 | 20 | @Override 21 | public R apply(Object input) { 22 | return delegate.apply(input); 23 | } 24 | 25 | public R apply(Object input, int endRecursionDepth) { 26 | return delegate.endRecursionAtDepth(endRecursionDepth).apply(input); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/chains/ConditionedMapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | import static java.util.Objects.requireNonNull; 8 | 9 | import java.util.function.BiFunction; 10 | import java.util.function.Function; 11 | import java.util.function.Predicate; 12 | 13 | final class ConditionedMapper implements BiFunction, R> { 14 | 15 | private final Predicate condition; 16 | private final BiFunction, R> mapper; 17 | private final Function conversion; 18 | 19 | public ConditionedMapper(Predicate condition, Function conversion, 20 | BiFunction, R> mapper) { 21 | this.condition = requireNonNull(condition, "condition must not be null"); 22 | this.conversion = requireNonNull(conversion, "conversion must not be null"); 23 | this.mapper = requireNonNull(mapper, "mapper must not be null"); 24 | } 25 | 26 | public Predicate condition() { 27 | return condition; 28 | } 29 | 30 | @Override 31 | public R apply(T input, Function callback) { 32 | T1 converted = conversion.apply(input); 33 | return mapper.apply(converted, callback); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/chains/MainChainBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | import static java.util.Objects.requireNonNull; 8 | 9 | import java.util.function.Function; 10 | 11 | final class MainChainBuilder extends AbstractChainBuilder, MainChainBuilder> { 12 | 13 | private Function endRecursionFunction = o -> null; 14 | private int defaultEndRecursionDepth = 6; 15 | 16 | public MainChainBuilder endRecursionWith(Function newEndRecursionFunction) { 17 | this.endRecursionFunction = requireNonNull(newEndRecursionFunction, "endRecursionFuntion must not be null"); 18 | return this; 19 | } 20 | 21 | public MainChainBuilder endRecursionAtDepth(int newDefaultEndRecursionDepth) { 22 | this.defaultEndRecursionDepth = newDefaultEndRecursionDepth; 23 | return this; 24 | } 25 | 26 | @Override 27 | Chain build() { 28 | return new Chain<>(new Branch(this), endRecursionFunction, defaultEndRecursionDepth); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/java/org/tensorics/core/util/names/NameRepository.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /** 3 | * 4 | * This file is part of streaming pool (http://www.streamingpool.org). 5 | * 6 | * Copyright (c) 2017-present, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.util.names; 24 | 25 | import com.google.common.annotations.Beta; 26 | 27 | /** 28 | * Indicates a repository of names for any object 29 | */ 30 | @Beta 31 | public interface NameRepository { 32 | 33 | /** 34 | * Returns the name for the specified object or {@code null} in case the repository does not know about the object. 35 | * 36 | * @param object the object for which to retrieve the nam 37 | * @return a proper name for the given object, or {@code null} if the object is not known by the repository. 38 | */ 39 | String nameFor(Object object); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/java/org/tensorics/incubate/function/AnalyticalFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.incubate.function; 24 | 25 | /** 26 | * A function for which the output for any input value can be calculated from an (internal) analytical expression. 27 | * 28 | * @author agorzaws 29 | * @param the type of the independent variable of the function (input) 30 | * @param the type of the dependent variable of the function (output) 31 | */ 32 | public interface AnalyticalFunction, Y> extends ContinuousFunction { 33 | 34 | String toText(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/incubate/function/ContinuousFunction.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.incubate.function; 24 | 25 | /** 26 | * A function for which the output can be retrieved for any input value. 27 | * 28 | * @author agorzaws 29 | * @param the type of the independent variable of the function (input) 30 | * @param the type of the dependent variable of the function (output) 31 | */ 32 | public interface ContinuousFunction, Y> extends KeyValueFunction { 33 | 34 | /* only marker at the moment */ 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/tensorics/incubate/function/IllegalDiscreteFunctionUsageException.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.incubate.function; 24 | 25 | /** 26 | * This exception is thrown, if a discrete function is use in a wrong way. 27 | * 28 | * @author agorzaws 29 | */ 30 | public class IllegalDiscreteFunctionUsageException extends RuntimeException { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | public IllegalDiscreteFunctionUsageException(String message) { 35 | super(message); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/tensorics/incubate/function/InterpolationStrategy.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.incubate.function; 24 | 25 | import java.io.Serializable; 26 | 27 | /** 28 | * A strategy defines how to calculate output values of a function from the a finite set of discrete values (from a 29 | * discrete function). 30 | * 31 | * @author agorzaws 32 | * @param the type of the independent variable (in) 33 | * @param the type of the dependent variable (output) 34 | */ 35 | public interface InterpolationStrategy, Y> extends Serializable { 36 | 37 | Y interpolate(X xValue, DiscreteFunction function); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/java/org/tensorics/incubate/spaces/Metric.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.incubate.spaces; 2 | 3 | /** 4 | * Defines a (positive) distance between two points (within a space). 5 | * 6 | * @author kaifox 7 | * @see https://en.wikipedia.org/wiki/Metric_(mathematics) 8 | * 9 | */ 10 | public interface Metric { 11 | 12 | V distance(T left, T right); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/AllSerializableHaveUidTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core; 6 | 7 | import org.tensorics.core.testing.SerializableHasUid; 8 | 9 | public class AllSerializableHaveUidTest extends SerializableHasUid { 10 | 11 | public AllSerializableHaveUidTest() { 12 | super(PackageReference.packageName()); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/PackageReference.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core; 6 | 7 | /** 8 | * This is used as a reference only. All classpath scanning for the pojo tests starts in the package where this class 9 | * resides. 10 | * 11 | * @author kfuchsbe 12 | */ 13 | public final class PackageReference { 14 | private PackageReference() { 15 | /* Never to be initialized */ 16 | } 17 | 18 | public static String packageName() { 19 | return PackageReference.class.getPackage().getName(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/TransportableEntitiesFulfillContractTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core; 6 | 7 | import org.tensorics.core.commons.options.Environment; 8 | import org.tensorics.core.commons.options.Option; 9 | import org.tensorics.core.math.operations.BinaryFunction; 10 | import org.tensorics.core.math.operations.CreationOperation; 11 | import org.tensorics.core.math.operations.UnaryOperation; 12 | import org.tensorics.core.math.structures.Structure; 13 | import org.tensorics.core.quantity.operations.AbstractQuantityOperation; 14 | import org.tensorics.core.tensor.Position; 15 | import org.tensorics.core.tensor.Shape; 16 | import org.tensorics.core.tensorbacked.Tensorbacked; 17 | import org.tensorics.core.testing.TransportableEntityFulfilled; 18 | import org.tensorics.core.tree.domain.Node; 19 | 20 | public class TransportableEntitiesFulfillContractTest extends TransportableEntityFulfilled { 21 | 22 | public TransportableEntitiesFulfillContractTest() { 23 | super(PackageReference.packageName(), Node.class, BinaryFunction.class, UnaryOperation.class, 24 | CreationOperation.class, AbstractQuantityOperation.class, Structure.class, Tensorbacked.class, 25 | Shape.class, Position.class, Environment.class, Option.class); 26 | /* NOTE: Tensor is not in this list, because Abstract tensor has a final equals/hashcode implementation */ 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/expressions/LatestOfExpressionTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.expressions; 6 | 7 | import static java.util.Arrays.asList; 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | import static org.tensorics.core.expressions.LatestOfExpression.latestOf; 10 | import static org.tensorics.core.tree.domain.ResolvedExpression.of; 11 | 12 | import java.util.Arrays; 13 | 14 | import org.junit.Before; 15 | import org.junit.Test; 16 | import org.tensorics.core.resolve.engine.ResolvingEngine; 17 | import org.tensorics.core.resolve.engine.ResolvingEngines; 18 | import org.tensorics.core.tree.domain.Expression; 19 | import org.tensorics.core.tree.domain.ResolvedExpression; 20 | 21 | public class LatestOfExpressionTest { 22 | 23 | private ResolvingEngine engine; 24 | 25 | @Before 26 | public void setUp() { 27 | engine = ResolvingEngines.defaultEngine(); 28 | } 29 | 30 | @Test 31 | public void testLatestValue() { 32 | Expression> buffer = ResolvedExpression.of(Arrays.asList(1, 2, 3, 4)); 33 | Expression latestFromBuffer = latestOf(buffer); 34 | 35 | assertThat(engine.resolve(latestFromBuffer)).isEqualTo(4); 36 | } 37 | 38 | @Test 39 | public void equality() { 40 | assertThat(latestOf(of(asList(new Integer(300))))).isEqualTo(latestOf(of(asList(300)))); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/fields/doubles/StructuresTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.fields.doubles; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class StructuresTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(Structures.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/function/DiscreteFunctionVs1DTensorWithCommonCoordinatesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.function; 6 | 7 | import org.junit.Before; 8 | import org.junit.Ignore; 9 | import org.tensorics.core.lang.Tensorics; 10 | import org.tensorics.core.tensor.Position; 11 | import org.tensorics.core.tensor.TensorBuilder; 12 | 13 | /** 14 | * Extension of {@link AbstractDiscreteFunctionVs1DTensorTest} that focuses on testing 1D tensors which have coordinates 15 | * in common. 16 | * 17 | * @author caguiler 18 | */ 19 | @Ignore 20 | public class DiscreteFunctionVs1DTensorWithCommonCoordinatesTest extends AbstractDiscreteFunctionVs1DTensorTest { 21 | 22 | @Before 23 | public void setUp() { 24 | TensorBuilder builder2 = Tensorics.builder(Double.class); 25 | TensorBuilder builder3 = Tensorics.builder(Double.class); 26 | 27 | for (double i = 0; i < 10; ++i) { 28 | Object[] coordinates = { i }; 29 | builder2.put(Position.of(coordinates), 2.0); 30 | Object[] coordinates1 = { i }; 31 | builder3.put(Position.of(coordinates1), 3.0); 32 | } 33 | 34 | two = builder2.build(); 35 | three = builder3.build(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/function/DiscreteFunctionVs1DTensorWithNoCommonCoordinatesTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.function; 6 | 7 | import org.junit.Before; 8 | import org.junit.Ignore; 9 | import org.tensorics.core.lang.Tensorics; 10 | import org.tensorics.core.tensor.Position; 11 | import org.tensorics.core.tensor.TensorBuilder; 12 | 13 | /** 14 | * Extension of {@link AbstractDiscreteFunctionVs1DTensorTest} that focuses on testing 1D tensors which have NO 15 | * coordinates in common. 16 | * 17 | * @author caguiler 18 | */ 19 | @Ignore 20 | public class DiscreteFunctionVs1DTensorWithNoCommonCoordinatesTest extends AbstractDiscreteFunctionVs1DTensorTest { 21 | 22 | @Before 23 | public void setUp() { 24 | TensorBuilder builder2 = Tensorics.builder(Double.class); 25 | TensorBuilder builder3 = Tensorics.builder(Double.class); 26 | 27 | for (double i = 1; i <= 10; ++i) { 28 | if (i % 2 == 0) { 29 | Object[] coordinates = { i }; 30 | builder2.put(Position.of(coordinates), 2.0); 31 | } else { 32 | Object[] coordinates = { i }; 33 | builder3.put(Position.of(coordinates), 3.0); 34 | } 35 | } 36 | 37 | two = builder2.build(); 38 | three = builder3.build(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/lang/TensorBackedThreeCoordinates.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.lang; 24 | 25 | import org.tensorics.core.tensor.Tensor; 26 | import org.tensorics.core.tensorbacked.AbstractTensorbacked; 27 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 28 | 29 | @Dimensions({ XCoordinate.class, YCoordinate.class, ZCoordinate.class }) 30 | public class TensorBackedThreeCoordinates extends AbstractTensorbacked { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | public TensorBackedThreeCoordinates(Tensor tensor) { 35 | super(tensor); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/lang/TensorBackedTwoCoordinates.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.lang; 24 | 25 | import org.tensorics.core.tensor.Tensor; 26 | import org.tensorics.core.tensorbacked.AbstractTensorbacked; 27 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 28 | 29 | @Dimensions({ XCoordinate.class, YCoordinate.class }) 30 | public class TensorBackedTwoCoordinates extends AbstractTensorbacked { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | public TensorBackedTwoCoordinates(Tensor tensor) { 35 | super(tensor); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/lang/TensoricExpressionsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.lang; 6 | 7 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 8 | 9 | import org.junit.Test; 10 | 11 | public class TensoricExpressionsTest { 12 | 13 | @Test 14 | public void verifyUtilityClass() { 15 | assertUtilityClass(TensoricExpressions.class); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/lang/TestCoordinate.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.lang; 24 | 25 | /** 26 | * For test purpose separate family of coordinates 27 | * 28 | * @author agorzaws 29 | */ 30 | public interface TestCoordinate extends Comparable { 31 | /* marker for test coordiantes */ 32 | } 33 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/resolve/engine/ResolvingEnginesTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.resolve.engine; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class ResolvingEnginesTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(ResolvingEngines.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/resolve/resolvers/ResolverRepositoriesTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.resolve.resolvers; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class ResolverRepositoriesTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(Resolvers.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/ShapesStrippingTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.tensor; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | 9 | import org.junit.Test; 10 | 11 | import com.google.common.collect.ImmutableSet; 12 | 13 | public class ShapesStrippingTest { 14 | 15 | @Test 16 | public void interfaceDimIsStrippedWhenPositionsAreInstances() { 17 | Shape shape = new Shape(ImmutableSet.of(Dim1.class), ImmutableSet.of(Position.of(Dim1Enum.P1))); 18 | Shape stripped = Shapes.dimensionStripped(shape, ImmutableSet.of(Dim1.class)); 19 | assertThat(stripped.dimensionality()).isEqualTo(0); 20 | } 21 | 22 | private interface Dim1 { 23 | /* Only for testing */ 24 | } 25 | 26 | private enum Dim1Enum implements Dim1 { 27 | P1, 28 | P2; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/TensorEqualityTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.tensor; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | import static org.tensorics.core.lang.Tensorics.scalarOf; 9 | 10 | import java.util.Collections; 11 | 12 | import org.junit.Test; 13 | import org.tensorics.core.tensor.ImmutableTensor.Builder; 14 | 15 | public class TensorEqualityTest { 16 | 17 | private static final String A_VALUE = "aValue"; 18 | 19 | @Test 20 | public void scalarIsEqualToZerodimTensor() { 21 | assertThat(scalarOf(A_VALUE)).isEqualTo(zeroDimensionalOf(A_VALUE)); 22 | } 23 | 24 | @Test 25 | public void zerodimTensorIsEqualToScalar() { 26 | assertThat(zeroDimensionalOf(A_VALUE)).isEqualTo(scalarOf(A_VALUE)); 27 | } 28 | 29 | @Test 30 | public void differentContextsAreNotEqual() { 31 | assertThat(zeroDimensionalOf(A_VALUE)).isNotEqualTo(scalarOf(A_VALUE).withContext("aCoord")); 32 | } 33 | 34 | private static Tensor zeroDimensionalOf(T value) { 35 | Builder builder = ImmutableTensor.builder(Collections.> emptySet()); 36 | builder.put(Position.empty(), value); 37 | return builder.build(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/expressions/TensorExpressionsTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensor.expressions; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class TensorExpressionsTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(TensorExpressions.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/lang/TensorStructuralsTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensor.lang; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class TensorStructuralsTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(TensorStructurals.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/operations/OperationsTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensor.operations; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | import org.tensorics.core.math.Operations; 29 | 30 | public class OperationsTest { 31 | 32 | @Test 33 | public void verifyUtilityClass() { 34 | assertUtilityClass(Operations.class); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensor/variance/CoContraDimensionPairsTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensor.variance; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class CoContraDimensionPairsTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(CoContraDimensionPairs.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/NoAnnotationPresentOrbit.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked; 24 | 25 | import org.tensorics.core.tensor.Tensor; 26 | import org.tensorics.core.tensorbacked.orbit.AbstractOrbit; 27 | 28 | public class NoAnnotationPresentOrbit extends AbstractOrbit { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | public NoAnnotationPresentOrbit(Tensor tensor) { 33 | super(tensor); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/ValueTypeDeterminationTest.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked; 2 | 3 | import org.junit.Test; 4 | import org.tensorics.core.tensor.Tensor; 5 | import org.tensorics.core.tensorbacked.AbstractTensorbacked; 6 | import org.tensorics.core.tensorbacked.TensorbackedInternals; 7 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 8 | import org.tensorics.core.tensorbacked.dimtyped.Tensorbacked1d; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | 12 | public class ValueTypeDeterminationTest { 13 | 14 | @Test 15 | public void valueTypeWorksForInherited() { 16 | Class valueType = TensorbackedInternals.valueTypeFrom(AnInheritedTensorbacked.class); 17 | assertThat(valueType).isEqualTo(Double.class); 18 | } 19 | 20 | @Test 21 | public void valueTypeWorksForInterface() { 22 | Class valueType = TensorbackedInternals.valueTypeFrom(AnInterfaceDerivedTensorbacked.class); 23 | assertThat(valueType).isEqualTo(Double.class); 24 | } 25 | 26 | @Dimensions({String.class, Integer.class}) 27 | public static class AnInheritedTensorbacked extends AbstractTensorbacked { 28 | 29 | public AnInheritedTensorbacked(Tensor tensor) { 30 | super(tensor); 31 | } 32 | 33 | } 34 | 35 | public interface AnInterfaceDerivedTensorbacked extends Tensorbacked1d { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/dimtyped/DimtypedOperationsTest.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.dimtyped; 2 | 3 | import org.assertj.core.api.Assertions; 4 | import org.junit.Rule; 5 | import org.junit.Test; 6 | import org.junit.rules.ExpectedException; 7 | import org.tensorics.core.lang.TensoricDoubles; 8 | import org.tensorics.core.lang.Tensorics; 9 | 10 | import java.util.NoSuchElementException; 11 | import java.util.Set; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | 15 | public class DimtypedOperationsTest { 16 | 17 | @Rule 18 | public ExpectedException thrown = ExpectedException.none(); 19 | 20 | 21 | @Test 22 | public void tensorbacked1dElementMultiplication() { 23 | ADoubleBackedVector vector = Tensorics.builderFor1D(ADoubleBackedVector.class).put("a", 1.2).build(); 24 | 25 | ADoubleBackedVector newVector = TensoricDoubles.calculate(vector).elementTimesV(2.0); 26 | Assertions.assertThat(newVector.get("a")).isEqualTo(2.4); 27 | } 28 | 29 | 30 | public interface ADoubleBackedVector extends Tensorbacked1d { 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/expressions/TensorbackedExpressionsTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.expressions; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class TensorbackedExpressionsTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(TensorbackedExpressions.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/interfacebacked/AnyOtherOrbitIf.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.interfacebacked; 2 | 3 | import org.tensorics.core.tensorbacked.dimtyped.Tensorbacked2d; 4 | import org.tensorics.core.tensorbacked.orbit.coordinates.Bpm; 5 | import org.tensorics.core.tensorbacked.orbit.coordinates.Plane; 6 | 7 | public interface AnyOtherOrbitIf extends Tensorbacked2d { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/interfacebacked/DimtypedAndAnnotationPresentOrbit.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.interfacebacked; 2 | 3 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 4 | import org.tensorics.core.tensorbacked.dimtyped.Tensorbacked2d; 5 | import org.tensorics.core.tensorbacked.orbit.coordinates.Bpm; 6 | import org.tensorics.core.tensorbacked.orbit.coordinates.Plane; 7 | 8 | @Dimensions({Bpm.class}) 9 | /* This class is for testing only and has on purpose an annotation contradicting to the tensorbacked1d interface. 10 | The test checks that there is no annotation present, if the interface is implemented. This is to exactly prevent such 11 | contradicting and thus confusing situations.*/ 12 | public interface DimtypedAndAnnotationPresentOrbit extends Tensorbacked2d { 13 | } 14 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/interfacebacked/SingleBeamOrbitIf.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.tensorbacked.interfacebacked; 2 | 3 | import org.tensorics.core.tensorbacked.dimtyped.Tensorbacked2d; 4 | import org.tensorics.core.tensorbacked.orbit.coordinates.Bpm; 5 | import org.tensorics.core.tensorbacked.orbit.coordinates.Plane; 6 | 7 | public interface SingleBeamOrbitIf extends Tensorbacked2d { 8 | /* No need to implement something */ 9 | } 10 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/AbstractOrbit.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit; 24 | 25 | import org.tensorics.core.tensor.Tensor; 26 | import org.tensorics.core.tensorbacked.AbstractTensorbacked; 27 | 28 | public abstract class AbstractOrbit extends AbstractTensorbacked { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | public AbstractOrbit(Tensor tensor) { 33 | super(tensor); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/SinglebeamOrbit.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit; 24 | 25 | import org.tensorics.core.tensor.Tensor; 26 | import org.tensorics.core.tensorbacked.annotation.Dimensions; 27 | import org.tensorics.core.tensorbacked.orbit.coordinates.Bpm; 28 | import org.tensorics.core.tensorbacked.orbit.coordinates.Plane; 29 | 30 | @Dimensions({ Plane.class, Bpm.class }) 31 | public class SinglebeamOrbit extends AbstractOrbit { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | public SinglebeamOrbit(Tensor tensor) { 36 | super(tensor); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/coordinates/Beam.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit.coordinates; 24 | 25 | public enum Beam implements OrbitCoordinate { 26 | B1, 27 | B2; 28 | } 29 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/coordinates/OrbitCoordinate.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit.coordinates; 24 | 25 | public interface OrbitCoordinate { 26 | /* only a marker interface */ 27 | } 28 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/coordinates/Plane.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit.coordinates; 24 | 25 | public enum Plane implements OrbitCoordinate { 26 | H, 27 | V; 28 | } 29 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tensorbacked/orbit/coordinates/Time.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tensorbacked.orbit.coordinates; 24 | 25 | public class Time implements OrbitCoordinate { 26 | private final long time; 27 | 28 | /** 29 | * @param time 30 | */ 31 | public Time(long time) { 32 | super(); 33 | this.time = time; 34 | } 35 | 36 | public long getTime() { 37 | return time; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/tree/domain/ResolvedExpressionTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.tree.domain; 24 | 25 | import static org.junit.Assert.assertEquals; 26 | 27 | import org.junit.Test; 28 | 29 | public class ResolvedExpressionTest { 30 | 31 | @Test 32 | public void getReturnsCorrectValue() { 33 | assertEquals(Integer.valueOf(1), ResolvedExpression.of(1).get()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/util/ClassesTest.java: -------------------------------------------------------------------------------- 1 | // @formatter:off 2 | /******************************************************************************* 3 | * 4 | * This file is part of tensorics. 5 | * 6 | * Copyright (c) 2008-2011, CERN. All rights reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | ******************************************************************************/ 21 | // @formatter:on 22 | 23 | package org.tensorics.core.util; 24 | 25 | import static org.tensorics.core.testing.TestUtil.assertUtilityClass; 26 | 27 | import org.junit.Test; 28 | 29 | public class ClassesTest { 30 | 31 | @Test 32 | public void verifyUtilityClass() { 33 | assertUtilityClass(Classes.class); 34 | } 35 | 36 | 37 | 38 | private class ParentClass { 39 | /* Only for testing the hierarchy */ 40 | } 41 | 42 | private class ChildClass extends ParentClass { 43 | /* Only for testing the hierarchy */ 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/util/JavaVersionsTries.java: -------------------------------------------------------------------------------- 1 | package org.tensorics.core.util; 2 | 3 | import org.junit.Test; 4 | 5 | public class JavaVersionsTries { 6 | 7 | @Test 8 | public void testJavaVersion() { 9 | System.out.println(System.getProperty("java.version")); 10 | System.out.println("11".compareTo("1.8") <= 0); 11 | System.out.println("11".compareTo("11") <= 0); 12 | System.out.println("11".compareTo("12") <= 0); 13 | System.out.println(JavaVersions.isAtLeastJava11()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/util/chains/ChainsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.chains; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | 9 | import java.util.Objects; 10 | 11 | import org.junit.Test; 12 | 13 | public class ChainsTest { 14 | 15 | @Test 16 | public void test() { 17 | Chain chain = Chains.chainFor(String.class).either((a) -> Objects.toString(a)).orElseThrow(); 18 | 19 | assertThat(chain.apply(Integer.valueOf(5))).isEqualTo("5"); 20 | 21 | int endRecursionDepth = 4; 22 | assertThat(chain.apply(Integer.valueOf(10), endRecursionDepth)).isEqualTo("10"); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/org/tensorics/core/util/names/ClasspathConstantScannerTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved. 3 | */ 4 | 5 | package org.tensorics.core.util.names; 6 | 7 | import org.apache.log4j.BasicConfigurator; 8 | import org.apache.log4j.Level; 9 | import org.apache.log4j.Logger; 10 | import org.assertj.core.api.Assertions; 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | 14 | import com.google.common.collect.ImmutableSet; 15 | 16 | public class ClasspathConstantScannerTest { 17 | 18 | public static final String A_TEST_VALUE_TO_BE_FOUND = "aTestValueToBeFound"; 19 | 20 | @BeforeClass 21 | public static final void setUpBeforeClass() { 22 | BasicConfigurator.configure(); 23 | Logger.getRootLogger().setLevel(Level.INFO); 24 | } 25 | 26 | @Test 27 | public void test() { 28 | long start = System.nanoTime(); 29 | ClasspathConstantScanner scanner = new ClasspathConstantScanner(ImmutableSet.of("org.tensorics.core.util.names")); 30 | NameRepository nameRepo = scanner.scan(); 31 | long end = System.nanoTime(); 32 | System.out.println("Done in " + Double.valueOf((end - start) / 1000000) / 1e3 + " secs."); 33 | Assertions.assertThat(nameRepo.nameFor(A_TEST_VALUE_TO_BE_FOUND)).isEqualTo("A_TEST_VALUE_TO_BE_FOUND"); 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------