Math.avt

Переключить прокрутку окна
Загрузить этот исходный код

/*
    Реализация среды исполнения языка программирования
    Объектно-ориентированный продвинутый векторный транслятор

    Copyright © 2021, 2024 Малик Разработчик

    Это свободная программа: вы можете перераспространять ее и/или изменять
    ее на условиях Меньшей Стандартной общественной лицензии GNU в том виде,
    в каком она была опубликована Фондом свободного программного обеспечения;
    либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии.

    Эта программа распространяется в надежде, что она будет полезной,
    но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
    или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Меньшей Стандартной
    общественной лицензии GNU.

    Вы должны были получить копию Меньшей Стандартной общественной лицензии GNU
    вместе с этой программой. Если это не так, см.
    <https://www.gnu.org/licenses/>.
*/

package avt.lang;

public service Math(Object)
{
    public static final byte2 I  = new byte2 { 0, 1 };
    public static final byte4 J  = new byte4 { 0, 0, 1, 0 };
    public static final byte4 K  = new byte4 { 0, 0, 0, 1 };
    public static final byte8 L  = new byte8 { 0, 0, 0, 0, 1, 0, 0, 0 };
    public static final byte8 IL = new byte8 { 0, 0, 0, 0, 0, 1, 0, 0 };
    public static final byte8 JL = new byte8 { 0, 0, 0, 0, 0, 0, 1, 0 };
    public static final byte8 KL = new byte8 { 0, 0, 0, 0, 0, 0, 0, 1 };

    public static final real E        = 0x1.5bf0a8b145769536p+1r;
    public static final real PI       = 0x1.921fb54442d1846ap+1r;
    public static final real LOG_2_10 = 0x1.a934f0979a3715fcp+1r;
    public static final real LOG_2_E  = 0x1.71547652b82fe178p+0r;
    public static final real LOG_10_2 = 0x1.34413509f79fef32p-2r;
    public static final real LOG_E_2  = 0x1.62e42fefa39ef358p-1r;

    private static final int ROUND_TO_NEAREST  = 0x0000;
    private static final int ROUND_DOWN        = 0x0400;
    private static final int ROUND_UP          = 0x0800;
    private static final int ROUND_TOWARD_ZERO = 0x0c00;

    private static final byte8 CONJ_MULT_BYTE   = new byte8 { 1, -1, -1, -1, -1, -1, -1, -1 };
    private static final int4  CONJ_XOR_FLOAT2  = new int4 { 0, -1 << 31, 0, 0 };
    private static final int8  CONJ_MULT_INT    = CONJ_MULT_BYTE;
    private static final int8  CONJ_XOR_FLOAT   = new int8 { 0, -1 << 31, -1 << 31, -1 << 31, -1 << 31, -1 << 31, -1 << 31, -1 << 31 };
    private static final long8 CONJ_MULT_LONG   = CONJ_MULT_BYTE;
    private static final long8 CONJ_XOR_DOUBLE  = new long8 { 0, -1L << 63, -1L << 63, -1L << 63, -1L << 63, -1L << 63, -1L << 63, -1L << 63 };

    private static final real CONST_MINUS_1_0    =         -1.0r;
    private static final real CONST_0_333333333  = +1.0r / +3.0r;
    private static final real CONST_0_5          = +1.0r / +2.0r;
    private static final real CONST_2_0_PI       =    +2.0r * PI;
    private static final real DEGREES_PER_RADIAN =  +180.0r / PI;

    public static native int abs(int x);

    public static native int sum(byte2 x);

    public static native int sum(byte4 x);

    public static native int sum(byte8 x);

    public static native int sum(short2 x);

    public static native int sum(short4 x);

    public static native int sum(short8 x);

    public static native int2 conj(int2 x);

    public static native int4 conj(int4 x);

    public static native int8 conj(int8 x);

    public static native long abs(long x);

    public static native long sum(int2 x);

    public static native long sum(int4 x);

    public static native long sum(int8 x);

    public static native long sum(long2 x);

    public static native long sum(long4 x);

    public static native long sum(long8 x);

    public static native long2 conj(long2 x);

    public static native long4 conj(long4 x);

    public static native long8 conj(long8 x);

    public static native float abs(float x);

    public static native float2 conj(float2 x);

    public static native float2 inv(float2 x);

    public static native float4 conj(float4 x);

    public static native float4 inv(float4 x);

    public static native float8 conj(float8 x);

    public static native float8 inv(float8 x);

    public static native double abs(double x);

    public static native double sum(float2 x);

    public static native double sum(float4 x);

    public static native double sum(float8 x);

    public static native double sum(double2 x);

    public static native double sum(double4 x);

    public static native double sum(double8 x);

    public static native double2 rotc(real x);

    public static native double2 conj(double2 x);

    public static native double2 inv(double2 x);

    public static native double4 rotq(real x, double4 u);

    public static native double4 conj(double4 x);

    public static native double4 inv(double4 x);

    public static native double8 conj(double8 x);

    public static native double8 inv(double8 x);

    public static native real sumr(long2 x);

    public static native real sumr(long4 x);

    public static native real sumr(long8 x);

    public static native real sumr(double2 x);

    public static native real sumr(double4 x);

    public static native real sumr(double8 x);

    public static native real abs(int2 x);

    public static native real abs(int4 x);

    public static native real abs(int8 x);

    public static native real abs(long2 x);

    public static native real abs(long4 x);

    public static native real abs(long8 x);

    public static native real abs(float2 x);

    public static native real abs(float4 x);

    public static native real abs(float8 x);

    public static native real abs(double2 x);

    public static native real abs(double4 x);

    public static native real abs(double8 x);

    public static native real abs(real x);

    public static native real arg(int2 x);

    public static native real arg(int4 x);

    public static native real arg(int8 x);

    public static native real arg(long2 x);

    public static native real arg(long4 x);

    public static native real arg(long8 x);

    public static native real arg(float2 x);

    public static native real arg(float4 x);

    public static native real arg(float8 x);

    public static native real arg(double2 x);

    public static native real arg(double4 x);

    public static native real arg(double8 x);

    public static native real arg(int4 x, int i);

    public static native real arg(int8 x, int i);

    public static native real arg(long4 x, int i);

    public static native real arg(long8 x, int i);

    public static native real arg(float4 x, int i);

    public static native real arg(float8 x, int i);

    public static native real arg(double4 x, int i);

    public static native real arg(double8 x, int i);

    public static native real sin(real x);

    public static native real cos(real x);

    public static native real tan(real x);

    public static native real asin(real x);

    public static native real acos(real x);

    public static native real atan(real x);

    public static native real exp(real x);

    public static native real exp2(real x);

    public static native real exp10(real x);

    public static native real log(real x);

    public static native real log2(real x);

    public static native real log10(real x);

    public static native real sqrt(real x);

    public static native real cbrt(real x);

    public static native real sinh(real x);

    public static native real cosh(real x);

    public static native real tanh(real x);

    public static native real asinh(real x);

    public static native real acosh(real x);

    public static native real atanh(real x);

    public static native real ceil(real x);

    public static native real floor(real x);

    public static native real round(real x);

    public static native real intPart(real x);

    public static native real fracPart(real x);

    public static native real atan2(real x, real y);

    public static native real pow(real x, real y);

    public static real toRadians(real angleInDegrees) { return angleInDegrees / DEGREES_PER_RADIAN; }

    public static real toDegrees(real angleInRadians) { return angleInRadians * DEGREES_PER_RADIAN; }
}