Debian Codegraph @

lib/proc/proc_distance.c

raw symbols SCIP
1 /*
2 Copyright (C) 2024 Sutou Kouhei <[email protected]>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "../grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/
20 #include "../grn_distance.h"cxx . . $ `<file>/lib/grn_distance.h`/
21
22 #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/
23
24 static grn_objcxx . . $ grn_obj# *
25 func_distance_cosinecxx . . $ func_distance_cosine(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
26 int n_args,
27 grn_objcxx . . $ grn_obj# **args,
28 grn_user_datacxx . . $ grn_user_data# *user_data)
29 {
30 const char *function_name = "distance_cosine";
31
32 grn_objcxx . . $ grn_obj# *distance = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_FLOAT32cxx . . $ GRN_DB_FLOAT32., 0);
33 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, 0.0);
34
35 if (n_args != 2) {
36 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
37 GRN_INVALID_ARGUMENT,
38 "%s(): wrong number of arguments (%d for 2)",
39 function_name,
40 n_args);
41 return distance;
42 }
43
44 grn_objcxx . . $ grn_obj# *vector1 = args[0];
45 grn_objcxx . . $ grn_obj# *vector2 = args[1];
46 float distance_raw = grn_distance_cosinecxx . . $ grn_distance_cosine(540677c5b0a4fe92).(ctx, vector1, vector2);
47 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, distance_raw);
48
49 return distance;
50 }
51
52 void
53 grn_proc_init_distance_cosinecxx . . $ grn_proc_init_distance_cosine(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
54 {
55 grn_objcxx . . $ grn_obj# *proc = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
56 "distance_cosine",
57 -1,
58 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
59 func_distance_cosinecxx . . $ func_distance_cosine(fd082858389c8bb0).,
60 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
61 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
62 0,
63 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
64 grn_proc_set_appliercxx . . $ grn_proc_set_applier(5e518908f149fea).(ctx, proc, grn_distance_cosine_appliercxx . . $ grn_distance_cosine_applier(6580e31ad1f8e719).);
65 }
66
67 static grn_objcxx . . $ grn_obj# *
68 func_distance_inner_productcxx . . $ func_distance_inner_product(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
69 int n_args,
70 grn_objcxx . . $ grn_obj# **args,
71 grn_user_datacxx . . $ grn_user_data# *user_data)
72 {
73 const char *function_name = "distance_inner_product";
74
75 grn_objcxx . . $ grn_obj# *distance = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_FLOAT32cxx . . $ GRN_DB_FLOAT32., 0);
76 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, 0.0);
77
78 if (n_args != 2) {
79 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
80 GRN_INVALID_ARGUMENT,
81 "%s(): wrong number of arguments (%d for 2)",
82 function_name,
83 n_args);
84 return distance;
85 }
86
87 grn_objcxx . . $ grn_obj# *vector1 = args[0];
88 grn_objcxx . . $ grn_obj# *vector2 = args[1];
89 float distance_raw = grn_distance_inner_productcxx . . $ grn_distance_inner_product(540677c5b0a4fe92).(ctx, vector1, vector2);
90 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, distance_raw);
91
92 return distance;
93 }
94
95 void
96 grn_proc_init_distance_inner_productcxx . . $ grn_proc_init_distance_inner_product(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
97 {
98 grn_objcxx . . $ grn_obj# *proc = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
99 "distance_inner_product",
100 -1,
101 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
102 func_distance_inner_productcxx . . $ func_distance_inner_product(fd082858389c8bb0).,
103 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
104 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
105 0,
106 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
107 grn_proc_set_appliercxx . . $ grn_proc_set_applier(5e518908f149fea).(ctx, proc, grn_distance_inner_product_appliercxx . . $ grn_distance_inner_product_applier(6580e31ad1f8e719).);
108 }
109
110 static grn_objcxx . . $ grn_obj# *
111 func_distance_l1_normcxx . . $ func_distance_l1_norm(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
112 int n_args,
113 grn_objcxx . . $ grn_obj# **args,
114 grn_user_datacxx . . $ grn_user_data# *user_data)
115 {
116 const char *function_name = "distance_l1_norm";
117
118 grn_objcxx . . $ grn_obj# *distance = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_FLOAT32cxx . . $ GRN_DB_FLOAT32., 0);
119 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, 0.0);
120
121 if (n_args != 2) {
122 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
123 GRN_INVALID_ARGUMENT,
124 "%s(): wrong number of arguments (%d for 2)",
125 function_name,
126 n_args);
127 return distance;
128 }
129
130 grn_objcxx . . $ grn_obj# *vector1 = args[0];
131 grn_objcxx . . $ grn_obj# *vector2 = args[1];
132 float distance_raw = grn_distance_l1_normcxx . . $ grn_distance_l1_norm(540677c5b0a4fe92).(ctx, vector1, vector2);
133 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, distance_raw);
134
135 return distance;
136 }
137
138 void
139 grn_proc_init_distance_l1_normcxx . . $ grn_proc_init_distance_l1_norm(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
140 {
141 grn_objcxx . . $ grn_obj# *proc = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
142 "distance_l1_norm",
143 -1,
144 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
145 func_distance_l1_normcxx . . $ func_distance_l1_norm(fd082858389c8bb0).,
146 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
147 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
148 0,
149 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
150 grn_proc_set_appliercxx . . $ grn_proc_set_applier(5e518908f149fea).(ctx, proc, grn_distance_l1_norm_appliercxx . . $ grn_distance_l1_norm_applier(6580e31ad1f8e719).);
151 }
152
153 static grn_objcxx . . $ grn_obj# *
154 func_distance_l2_norm_squaredcxx . . $ func_distance_l2_norm_squared(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
155 int n_args,
156 grn_objcxx . . $ grn_obj# **args,
157 grn_user_datacxx . . $ grn_user_data# *user_data)
158 {
159 const char *function_name = "distance_l2_norm_squared";
160
161 grn_objcxx . . $ grn_obj# *distance = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_FLOAT32cxx . . $ GRN_DB_FLOAT32., 0);
162 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, 0.0);
163
164 if (n_args != 2) {
165 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
166 GRN_INVALID_ARGUMENT,
167 "%s(): wrong number of arguments (%d for 2)",
168 function_name,
169 n_args);
170 return distance;
171 }
172
173 grn_objcxx . . $ grn_obj# *vector1 = args[0];
174 grn_objcxx . . $ grn_obj# *vector2 = args[1];
175 float distance_raw = grn_distance_l2_norm_squaredcxx . . $ grn_distance_l2_norm_squared(540677c5b0a4fe92).(ctx, vector1, vector2);
176 GRN_FLOAT32_SETcxx . . $ `include/groonga/groonga.h:2929:9`!(ctx, distance, distance_raw);
177
178 return distance;
179 }
180
181 void
182 grn_proc_init_distance_l2_norm_squaredcxx . . $ grn_proc_init_distance_l2_norm_squared(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
183 {
184 grn_objcxx . . $ grn_obj# *proc = grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
185 "distance_l2_norm_squared",
186 -1,
187 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
188 func_distance_l2_norm_squaredcxx . . $ func_distance_l2_norm_squared(fd082858389c8bb0).,
189 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
190 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
191 0,
192 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
193 grn_proc_set_appliercxx . . $ grn_proc_set_applier(5e518908f149fea).(ctx, proc, grn_distance_l2_norm_squared_appliercxx . . $ grn_distance_l2_norm_squared_applier(6580e31ad1f8e719).);
194 }