Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
eec76edb
Commit
eec76edb
authored
Jun 3, 2020
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Allow conversion of scalars to R^1 for builtin functions arguments
parent
285280e3
No related branches found
No related tags found
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp
+66
-28
66 additions, 28 deletions
src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp
src/language/ast/ASTNodeNaturalConversionChecker.cpp
+0
-1
0 additions, 1 deletion
src/language/ast/ASTNodeNaturalConversionChecker.cpp
with
66 additions
and
29 deletions
src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp
+
66
−
28
View file @
eec76edb
...
...
@@ -39,6 +39,39 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData
auto
get_function_argument_converter_for_vector
=
[
&
](
const
auto
&
parameter_v
)
->
std
::
unique_ptr
<
IFunctionArgumentConverter
>
{
using
ParameterT
=
std
::
decay_t
<
decltype
(
parameter_v
)
>
;
if
constexpr
(
std
::
is_same_v
<
ParameterT
,
TinyVector
<
1
>>
)
{
switch
(
argument_node_sub_data_type
.
m_data_type
)
{
case
ASTNodeDataType
::
vector_t
:
{
if
(
argument_node_sub_data_type
.
m_data_type
.
dimension
()
==
1
)
{
return
std
::
make_unique
<
FunctionTinyVectorArgumentConverter
<
ParameterT
,
ParameterT
>>
(
argument_number
);
}
else
{
// LCOV_EXCL_START
throw
parse_error
(
"unexpected error: invalid argument dimension"
,
std
::
vector
{
argument_node_sub_data_type
.
m_parent_node
.
begin
()});
// LCOV_EXCL_STOP
}
}
case
ASTNodeDataType
::
bool_t
:
{
return
std
::
make_unique
<
FunctionTinyVectorArgumentConverter
<
ParameterT
,
bool
>>
(
argument_number
);
}
case
ASTNodeDataType
::
int_t
:
{
return
std
::
make_unique
<
FunctionTinyVectorArgumentConverter
<
ParameterT
,
int64_t
>>
(
argument_number
);
}
case
ASTNodeDataType
::
unsigned_int_t
:
{
return
std
::
make_unique
<
FunctionTinyVectorArgumentConverter
<
ParameterT
,
uint64_t
>>
(
argument_number
);
}
case
ASTNodeDataType
::
double_t
:
{
return
std
::
make_unique
<
FunctionTinyVectorArgumentConverter
<
ParameterT
,
double
>>
(
argument_number
);
}
// LCOV_EXCL_START
default
:
{
throw
parse_error
(
"unexpected error: invalid argument type"
,
std
::
vector
{
argument_node_sub_data_type
.
m_parent_node
.
begin
()});
}
// LCOV_EXCL_STOP
}
}
else
{
switch
(
argument_node_sub_data_type
.
m_data_type
)
{
case
ASTNodeDataType
::
vector_t
:
{
if
(
argument_node_sub_data_type
.
m_data_type
.
dimension
()
==
parameter_v
.
dimension
())
{
...
...
@@ -75,6 +108,7 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData
}
// LCOV_EXCL_STOP
}
}
};
auto
get_function_argument_to_string_converter
=
[
&
]()
->
std
::
unique_ptr
<
IFunctionArgumentConverter
>
{
...
...
@@ -318,7 +352,11 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData
}
};
if
(
parameter_type
==
ASTNodeDataType
::
vector_t
and
parameter_type
.
dimension
()
==
1
)
{
ASTNodeNaturalConversionChecker
{
argument_node_sub_data_type
,
ASTNodeDataType
::
double_t
};
}
else
{
ASTNodeNaturalConversionChecker
{
argument_node_sub_data_type
,
parameter_type
};
}
return
get_function_argument_converter_for_argument_type
();
}
...
...
This diff is collapsed.
Click to expand it.
src/language/ast/ASTNodeNaturalConversionChecker.cpp
+
0
−
1
View file @
eec76edb
...
...
@@ -28,7 +28,6 @@ ASTNodeNaturalConversionChecker::_checkIsNaturalExpressionConversion(const ASTNo
const
ASTNodeDataType
&
target_data_type
)
const
{
if
(
target_data_type
==
ASTNodeDataType
::
vector_t
)
{
// Only R^d data is considered
switch
(
node
.
m_data_type
)
{
case
ASTNodeDataType
::
list_t
:
{
if
(
node
.
children
.
size
()
!=
target_data_type
.
dimension
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment