Repository navigation
Expand file tree
/
Copy pathtest_type_header.sql
More file actions
66 lines (55 loc) · 1.9 KB
/
Copy pathtest_type_header.sql
File metadata and controls
66 lines (55 loc) · 1.9 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
66
\pset linestyle unicode
\pset border 2
-- # Types
--
set client_min_messages = 'WARNING'; -- pragma:hide
create extension if not exists onesparse;
-- OneSparse exposes SuiteSparse:GraphBLAS objects as native Postgres
-- types. These types are:
\dT onesparse.*
-- ## Element Types
--
-- The GraphBLAS has both core types and user defined types that
-- define the value and structure of matrix elements. Currently
-- onesparse maps these Postgres types to GraphBLAS types.
-- SuiteSparse provides a wider variety of numeric types than Postgres
-- (unsigned ints, complex, user defined).
--
-- | Postgres Type Name | SuiteSparse Type Name |
-- |--------------------|-----------------------|
-- | smallint | int16 |
-- | integer | int32 |
-- | bigint | int64 |
-- | float | fp32 |
-- | double precision | fp64 |
-- | bool | bool |
--
-- Types can stored in tables in the database, they can be created by
-- casting the SuiteSparse type name to the `type` type:
select 'int32'::type;
-- Matrix, Vector and Scalar constructors take a type argument. The
-- name is implicity cast to type in this case. The two examples:
select matrix('int32');
select matrix('int32'::type);
-- ## User Defined Types
insert into user_defined_type (name, type_def) values
('tuple_fp64', 'typedef struct {int64_t k; double v;} tuple_fp64;');
--
select 'tuple_fp64'::type;
-- Are equivalent.
--
-- | OneSparse Name | SuiteSparse Name |
-- |----------------|------------------|
-- | bool | GrB_BOOL |
-- | int8 | GrB_INT8 |
-- | int16 | GrB_INT16 |
-- | int32 | GrB_INT32 |
-- | int64 | GrB_INT64 |
-- | uint8 | GrB_UINT8 |
-- | uint16 | GrB_UINT16 |
-- | uint32 | GrB_UINT32 |
-- | uint64 | GrB_UINT64 |
-- | fp32 | GrB_FP32 |
-- | fp64 | GrB_FP64 |
-- | fc32 | GxB_FC32 |
-- | fc64 | GxB_FC64 |