/*
 * Copyright 1997-2025 Optimatika
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.ojalgo.algebra;

import org.ojalgo.scalar.PrimitiveScalar;

/**
 * @author apete
 */
public interface NormedVectorSpace<T, N extends Comparable<N>> extends VectorSpace<T, N> {

    /**
     * @param comparedTo What to compare with
     * @return true if this is small compared to the magnitude of the input reference value.
     */
    default boolean isSmall(final double comparedTo) {
        return PrimitiveScalar.isSmall(comparedTo, this.norm());
    }

    /**
     * <code>this == this.normalised().multiply(this.norm())</code>
     *
     * @return The norm
     */
    double norm();

    /**
     * <code>this == this.normalised().multiply(this.norm())</code>
     * <p>
     * When <code>this.norm() == 0.0</code> it becomes arbitrary or undefined what this method should return.
     * It is up to specific implementors to document their behaviour in this case.
     *
     * @return A unit "vector"
     */
    T normalised();

    /**
     * @deprecated v57 Use {@link #normalised()} instead
     */
    @Deprecated
    default T signum() {
        return this.normalised();
    }

}
