1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
/*
* M_APM - mapmhsin.c
*
* Copyright (C) 2000 - 2007 Michael C. Ring
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted. Permission to distribute
* the modified code is granted. Modifications are to be distributed by
* using the file 'license.txt' as a template to modify the file header.
* 'license.txt' is available in the official MAPM distribution.
*
* This software is provided "as is" without express or implied warranty.
*/
/*
*
* This file contains the Hyperbolic SIN, COS, & TAN functions.
*/
#include "pgAdmin3.h"
#include "pgscript/utilities/mapm-lib/m_apm_lc.h"
/****************************************************************************/
/*
* sinh(x) == 0.5 * [ exp(x) - exp(-x) ]
*/
void m_apm_sinh(M_APM rr, int places, M_APM aa)
{
M_APM tmp1, tmp2, tmp3;
int local_precision;
tmp1 = M_get_stack_var();
tmp2 = M_get_stack_var();
tmp3 = M_get_stack_var();
local_precision = places + 4;
m_apm_exp(tmp1, local_precision, aa);
m_apm_reciprocal(tmp2, local_precision, tmp1);
m_apm_subtract(tmp3, tmp1, tmp2);
m_apm_multiply(tmp1, tmp3, MM_0_5);
m_apm_round(rr, places, tmp1);
M_restore_stack(3);
}
/****************************************************************************/
/*
* cosh(x) == 0.5 * [ exp(x) + exp(-x) ]
*/
void m_apm_cosh(M_APM rr, int places, M_APM aa)
{
M_APM tmp1, tmp2, tmp3;
int local_precision;
tmp1 = M_get_stack_var();
tmp2 = M_get_stack_var();
tmp3 = M_get_stack_var();
local_precision = places + 4;
m_apm_exp(tmp1, local_precision, aa);
m_apm_reciprocal(tmp2, local_precision, tmp1);
m_apm_add(tmp3, tmp1, tmp2);
m_apm_multiply(tmp1, tmp3, MM_0_5);
m_apm_round(rr, places, tmp1);
M_restore_stack(3);
}
/****************************************************************************/
/*
* tanh(x) == [ exp(x) - exp(-x) ] / [ exp(x) + exp(-x) ]
*/
void m_apm_tanh(M_APM rr, int places, M_APM aa)
{
M_APM tmp1, tmp2, tmp3, tmp4;
int local_precision;
tmp1 = M_get_stack_var();
tmp2 = M_get_stack_var();
tmp3 = M_get_stack_var();
tmp4 = M_get_stack_var();
local_precision = places + 4;
m_apm_exp(tmp1, local_precision, aa);
m_apm_reciprocal(tmp2, local_precision, tmp1);
m_apm_subtract(tmp3, tmp1, tmp2);
m_apm_add(tmp4, tmp1, tmp2);
m_apm_divide(tmp1, local_precision, tmp3, tmp4);
m_apm_round(rr, places, tmp1);
M_restore_stack(4);
}
/****************************************************************************/
|