-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacb_norm_main.c
More file actions
65 lines (54 loc) · 1.83 KB
/
acb_norm_main.c
File metadata and controls
65 lines (54 loc) · 1.83 KB
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
/*
Author: Randall L. Rathbun
Date: Tue 11 Nov 2025 09:51:26 AM PST
This file is intended to become part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include "acb_set_str.h"
#include "autoset_bin_prec.h"
#include "acb_norm.h"
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage: %s <input_string>\n", argv[0]);
return 1;
}
printf("Raw: |%s|\n",argv[1]);
int error = 0;
arb_t norm;
arb_init(norm);
acb_t result;
acb_init(result);
// try to auto-set the precision
slong bit_precision = autoset_bin_prec(argv[1]);
if (bit_precision < 128 ) { bit_precision = 128; }
double d_digits = bit_precision;
d_digits = d_digits / 3.321928094887362;
slong digits = d_digits; // Example precision
printf("Using bit precision = %d decimal digits: %d\n",bit_precision, digits);
// creating the acb_t complex number
error = acb_set_str(result, argv[1], bit_precision);
if (error) {
fprintf(stderr, "Error setting complex number from string.\n");
} else {
printf("Complex number: [");
arb_printd(acb_realref(result), 20); // Print real part
printf("] + [");
arb_printd(acb_imagref(result), 20); // Print imaginary part
printf("]*i\n");
}
// finding the norm(C)
printf("Testing norm function:\n");
acb_norm(norm, result, bit_precision);
printf("Complex modulus or norm: ");
arb_printd(norm, digits);
printf("\n");
arb_clear(norm);
acb_clear(result);
return 0;
}