logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

fabs.3p (2948B)


  1. '\" et
  2. .TH FABS "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. fabs,
  12. fabsf,
  13. fabsl
  14. \(em absolute value function
  15. .SH SYNOPSIS
  16. .LP
  17. .nf
  18. #include <math.h>
  19. .P
  20. double fabs(double \fIx\fP);
  21. float fabsf(float \fIx\fP);
  22. long double fabsl(long double \fIx\fP);
  23. .fi
  24. .SH DESCRIPTION
  25. The functionality described on this reference page is aligned with the
  26. ISO\ C standard. Any conflict between the requirements described here and the
  27. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  28. .P
  29. These functions shall compute the absolute value of their argument
  30. .IR x ,|\c
  31. .IR x |.
  32. .SH "RETURN VALUE"
  33. Upon successful completion, these functions shall return the absolute
  34. value of
  35. .IR x .
  36. .P
  37. If
  38. .IR x
  39. is NaN, a NaN shall be returned.
  40. .P
  41. If
  42. .IR x
  43. is \(+-0, +0 shall be returned.
  44. .P
  45. If
  46. .IR x
  47. is \(+-Inf, +Inf shall be returned.
  48. .SH ERRORS
  49. No errors are defined.
  50. .LP
  51. .IR "The following sections are informative."
  52. .SH EXAMPLES
  53. .SS "Computing the 1-Norm of a Floating-Point Vector"
  54. .P
  55. This example shows the use of
  56. \fIfabs\fR()
  57. to compute the 1-norm of a vector defined as follows:
  58. .sp
  59. .RS 4
  60. .nf
  61. norm1(v) = |v[0]| + |v[1]| + ... + |v[n-1]|
  62. .fi
  63. .P
  64. .RE
  65. .P
  66. where |\fIx\fR| denotes the absolute value of \fIx\fR, \fIn\fR denotes
  67. the vector's dimension \fIv\fR[\fIi\fR] denotes the
  68. .IR i -th
  69. component of \fIv\fR (0\(<=\fIi\fR<\fIn\fR).
  70. .sp
  71. .RS 4
  72. .nf
  73. #include <math.h>
  74. .P
  75. double
  76. norm1(const double v[], const int n)
  77. {
  78. int i;
  79. double n1_v; /* 1-norm of v */
  80. .P
  81. n1_v = 0;
  82. for (i=0; i<n; i++) {
  83. n1_v += fabs (v[i]);
  84. }
  85. .P
  86. return n1_v;
  87. }
  88. .fi
  89. .P
  90. .RE
  91. .SH "APPLICATION USAGE"
  92. None.
  93. .SH RATIONALE
  94. None.
  95. .SH "FUTURE DIRECTIONS"
  96. None.
  97. .SH "SEE ALSO"
  98. .IR "\fIisnan\fR\^(\|)"
  99. .P
  100. The Base Definitions volume of POSIX.1\(hy2017,
  101. .IR "\fB<math.h>\fP"
  102. .\"
  103. .SH COPYRIGHT
  104. Portions of this text are reprinted and reproduced in electronic form
  105. from IEEE Std 1003.1-2017, Standard for Information Technology
  106. -- Portable Operating System Interface (POSIX), The Open Group Base
  107. Specifications Issue 7, 2018 Edition,
  108. Copyright (C) 2018 by the Institute of
  109. Electrical and Electronics Engineers, Inc and The Open Group.
  110. In the event of any discrepancy between this version and the original IEEE and
  111. The Open Group Standard, the original IEEE and The Open Group Standard
  112. is the referee document. The original Standard can be obtained online at
  113. http://www.opengroup.org/unix/online.html .
  114. .PP
  115. Any typographical or formatting errors that appear
  116. in this page are most likely
  117. to have been introduced during the conversion of the source files to
  118. man page format. To report such errors, see
  119. https://www.kernel.org/doc/man-pages/reporting_bugs.html .