1 /* $OpenBSD: econst.c,v 1.1 2011/07/02 18:11:01 martynas Exp $ */ 2 3 /* 4 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /* econst.c */ 20 /* e type constants used by high precision check routines */ 21 22 #include "ehead.h" 23 24 25 #if NE == 10 26 /* 0.0 */ 27 unsigned short ezero[NE] = 28 {0x0000, 0x0000, 0x0000, 0x0000, 29 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,}; 30 31 /* 5.0E-1 */ 32 unsigned short ehalf[NE] = 33 {0x0000, 0x0000, 0x0000, 0x0000, 34 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x3ffe,}; 35 36 /* 1.0E0 */ 37 unsigned short eone[NE] = 38 {0x0000, 0x0000, 0x0000, 0x0000, 39 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x3fff,}; 40 41 /* 2.0E0 */ 42 unsigned short etwo[NE] = 43 {0x0000, 0x0000, 0x0000, 0x0000, 44 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x4000,}; 45 46 /* 3.2E1 */ 47 unsigned short e32[NE] = 48 {0x0000, 0x0000, 0x0000, 0x0000, 49 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x4004,}; 50 51 /* 6.93147180559945309417232121458176568075500134360255E-1 */ 52 unsigned short elog2[NE] = 53 {0x40f3, 0xf6af, 0x03f2, 0xb398, 54 0xc9e3, 0x79ab, 0150717, 0013767, 0130562, 0x3ffe,}; 55 56 /* 1.41421356237309504880168872420969807856967187537695E0 */ 57 unsigned short esqrt2[NE] = 58 {0x1d6f, 0xbe9f, 0x754a, 0x89b3, 59 0x597d, 0x6484, 0174736, 0171463, 0132404, 0x3fff,}; 60 61 /* 3.14159265358979323846264338327950288419716939937511E0 */ 62 unsigned short epi[NE] = 63 {0x2902, 0x1cd1, 0x80dc, 0x628b, 64 0xc4c6, 0xc234, 0020550, 0155242, 0144417, 0040000,}; 65 66 /* 5.7721566490153286060651209008240243104215933593992E-1 */ 67 unsigned short eeul[NE] = { 68 0xd1be,0xc7a4,0076660,0063743,0111704,0x3ffe,}; 69 70 #else 71 72 /* 0.0 */ 73 unsigned short ezero[NE] = { 74 0, 0000000,0000000,0000000,0000000,0000000,}; 75 /* 5.0E-1 */ 76 unsigned short ehalf[NE] = { 77 0, 0000000,0000000,0000000,0100000,0x3ffe,}; 78 /* 1.0E0 */ 79 unsigned short eone[NE] = { 80 0, 0000000,0000000,0000000,0100000,0x3fff,}; 81 /* 2.0E0 */ 82 unsigned short etwo[NE] = { 83 0, 0000000,0000000,0000000,0100000,0040000,}; 84 /* 3.2E1 */ 85 unsigned short e32[NE] = { 86 0, 0000000,0000000,0000000,0100000,0040004,}; 87 /* 6.93147180559945309417232121458176568075500134360255E-1 */ 88 unsigned short elog2[NE] = { 89 0xc9e4,0x79ab,0150717,0013767,0130562,0x3ffe,}; 90 /* 1.41421356237309504880168872420969807856967187537695E0 */ 91 unsigned short esqrt2[NE] = { 92 0x597e,0x6484,0174736,0171463,0132404,0x3fff,}; 93 /* 2/sqrt(PI) = 94 * 1.12837916709551257389615890312154517168810125865800E0 */ 95 unsigned short eoneopi[NE] = { 96 0x71d5,0x688d,0012333,0135202,0110156,0x3fff,}; 97 /* 3.14159265358979323846264338327950288419716939937511E0 */ 98 unsigned short epi[NE] = { 99 0xc4c6,0xc234,0020550,0155242,0144417,0040000,}; 100 /* 5.7721566490153286060651209008240243104215933593992E-1 */ 101 unsigned short eeul[NE] = { 102 0xd1be,0xc7a4,0076660,0063743,0111704,0x3ffe,}; 103 #endif 104 extern unsigned short ezero[]; 105 extern unsigned short ehalf[]; 106 extern unsigned short eone[]; 107 extern unsigned short etwo[]; 108 extern unsigned short e32[]; 109 extern unsigned short elog2[]; 110 extern unsigned short esqrt2[]; 111 extern unsigned short eoneopi[]; 112 extern unsigned short epi[]; 113 extern unsigned short eeul[]; 114 115