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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
Copyright 2015 Ian Jauslin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Numerical constants (rational numbers and their square roots (including \sqrt{-1}=i))
*/
#ifndef NUMBER_H
#define NUMBER_H
#include "types.h"
// init
int init_Number(Number* number, int memory);
int free_Number(Number number);
// copy
int number_cpy(Number input, Number* output);
int number_cpy_noinit(Number input, Number* output);
// resize memory
int number_resize(Number* number, int newsize);
// add a value
int number_append(Q scalar, int base, Number* output);
// concatenate
int number_concat(Number input, Number* output);
// special numbers
Number number_zero();
Number number_one();
// find a base element
int number_find_base(int base, Number number);
// sort
int number_sort(Number number, int begin, int end);
// exchange terms (for sorting)
int number_exchange_terms(int index1, int index2, Number number);
// checks whether two numbers are equal
int number_compare(Number x1, Number x2);
// add (write result to second element)
int number_add_chain(Number input, Number* inout);
// add a single element
int number_add_elem(Q scalar, int base, Number* inout);
// create a new number
int number_add(Number x1, Number x2, Number* out);
// return the number
Number number_add_ret(Number x1, Number x_2);
// multiply
int number_prod(Number x1, Number x2, Number* out);
// write to second number
int number_prod_chain(Number input, Number* inout);
// return result
Number number_prod_ret(Number x1, Number x2);
// multiply by a rational
int number_Qprod_chain(Q q, Number* inout);
// write to output
int number_Qprod(Q q, Number x, Number* inout);
// return result
Number number_Qprod_ret(Q q, Number x);
// inverse
int number_inverse_inplace(Number* inout);
// write to output
int number_inverse(Number input, Number* output);
// return result
Number number_inverse_ret(Number x);
// quotient
int number_quot(Number x1, Number x2, Number* output);
int number_quot_chain(Number x1, Number* inout);
Number number_quot_ret(Number x1, Number x2);
// remove 0's
int number_simplify(Number in, Number* out);
// check whether a number is 0
int number_is_zero(Number x);
// approximate numerical expression
long double number_double_val(Number x);
// approximate numerical expression (as mpfr float)
int number_mpfr_val(mpfr_t out, Number x);
// print to string
int number_sprint(Number number, Char_Array* out);
// print to stdout
int number_print(Number number);
// read from a string
int str_to_Number(char* str, Number* number);
// char array input
int char_array_to_Number(Char_Array cstr_num, Number* number);
//------------------------ Number_Matrix --------------------------
// init
int init_Number_Matrix(Number_Matrix* matrix, int length);
int free_Number_Matrix(Number_Matrix matrix);
// Pauli matrices
int Pauli_matrix(int i, Number_Matrix* output);
#endif
|