Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outer function currently doesn't support input arrays of different sizes #144

Open
misungson opened this issue Mar 29, 2022 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@misungson
Copy link

misungson commented Mar 29, 2022

Describe the bug
outer function currently doesn't support input arrays of different sizes

To Reproduce
nc::NdArray<double> x = {1., 2.}; nc::NdArray<double> y = {1., 2., 3.}; auto output = nc::outer (x, z);

Expected behavior
output should be something like { {1, 2, 3}, {2, 4, 6} }

Code suggestions
In addition to below, it would be good for the function to flatten the input arrays.

`
template
NdArray outer(const NdArray& inArray1, const NdArray& inArray2)
{
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype);

const auto size1 = inArray1.size();
const auto size2 = inArray2.size();

auto returnArray = NdArray<dtype>(size1, size2);
for (uint32 row = 0; row < size1; ++row)
{
    const auto array1Value = inArray1[row];

    std::transform(inArray2.begin(), inArray2.end(), returnArray.begin(row),
        [array1Value](dtype value) -> dtype
        {
            return array1Value * value;
        });
}

return returnArray;

}
`

@dpilger26 dpilger26 self-assigned this Apr 4, 2022
@dpilger26 dpilger26 added the enhancement New feature or request label May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants