| To: | yyyyyyyyyyyyyyy@xxxxxxxxxxxxx |
|---|---|
| Subject: | Defect in XSH fabs |
| From: | yyyyyyyy@xxxxxxx |
| Date: | Wed, 16 Jul 2003 14:58:24 +0100 (BST) |
Defect report from : Loic Domaigne , personal interest
(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)
@ page 0 line 0 section fabs comment {fabs}
Problem:
Edition of Specification (Year): 2003
Defect code : 2. Omission
Missing example
Action:
Computing the 1-norm of a floating point vector
This example shows the use of fabs() to compute the 1-norm of a
vector defined as follows:
norm1(v) = |v[0]| + |v[1]| + ... + |v[n-1]|
where |x| denotes the absolute value of x,
n denotes the vector's dimension
v[i] denotes the i-th component of v (0<=i<n)
#include <math.h>
double
norm1(const double v[], /* vector components */
const int n /* vector dimension */
)
{
int i;
double n1_v; /* 1-norm of v */
n1_v = 0;
for (i=0; i<n; i++)
{
n1_v += fabs (v[i]);
}
return n1_v;
}
Note: you might derived similar functions using
fabsf() and fabsl().
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Defect in XSH Threads, jonhitchcock |
|---|---|
| Next by Date: | Defect in XSH exp, loic-dev |
| Previous by Thread: | Defect in XSH pthread_sigmask, loic-dev |
| Next by Thread: | Defect in XSH exp, loic-dev |
| Indexes: | [Date] [Thread] [All Lists] |