diff --git a/src/arithmetic.h b/IncludeFiles/arithmetic.h similarity index 100% rename from src/arithmetic.h rename to IncludeFiles/arithmetic.h diff --git a/src/arrayfn.h b/IncludeFiles/arrayfn.h similarity index 100% rename from src/arrayfn.h rename to IncludeFiles/arrayfn.h diff --git a/src/arrayview.h b/IncludeFiles/arrayview.h similarity index 100% rename from src/arrayview.h rename to IncludeFiles/arrayview.h diff --git a/src/boolean.h b/IncludeFiles/boolean.h similarity index 100% rename from src/boolean.h rename to IncludeFiles/boolean.h diff --git a/src/clause.h b/IncludeFiles/clause.h similarity index 100% rename from src/clause.h rename to IncludeFiles/clause.h diff --git a/src/complex.h b/IncludeFiles/complex.h similarity index 100% rename from src/complex.h rename to IncludeFiles/complex.h diff --git a/src/const.h b/IncludeFiles/const.h similarity index 100% rename from src/const.h rename to IncludeFiles/const.h diff --git a/src/control.h b/IncludeFiles/control.h similarity index 100% rename from src/control.h rename to IncludeFiles/control.h diff --git a/src/functional.h b/IncludeFiles/functional.h similarity index 100% rename from src/functional.h rename to IncludeFiles/functional.h diff --git a/src/integral.h b/IncludeFiles/integral.h similarity index 100% rename from src/integral.h rename to IncludeFiles/integral.h diff --git a/src/io.h b/IncludeFiles/io.h similarity index 100% rename from src/io.h rename to IncludeFiles/io.h diff --git a/src/iterator.h b/IncludeFiles/iterator.h similarity index 100% rename from src/iterator.h rename to IncludeFiles/iterator.h diff --git a/src/librarylink.h b/IncludeFiles/librarylink.h similarity index 100% rename from src/librarylink.h rename to IncludeFiles/librarylink.h diff --git a/src/linalgebra.h b/IncludeFiles/linalgebra.h similarity index 100% rename from src/linalgebra.h rename to IncludeFiles/linalgebra.h diff --git a/src/listable.h b/IncludeFiles/listable.h similarity index 100% rename from src/listable.h rename to IncludeFiles/listable.h diff --git a/src/macros.h b/IncludeFiles/macros.h similarity index 100% rename from src/macros.h rename to IncludeFiles/macros.h diff --git a/IncludeFiles/math_base.h b/IncludeFiles/math_base.h new file mode 100644 index 0000000..81a79c0 --- /dev/null +++ b/IncludeFiles/math_base.h @@ -0,0 +1,85 @@ +// Compiler from Wolfram Language to C++ +// +// Copyright 2019 Tianhuan Lu +// +// 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. +// + +#pragma once + +#include + +#include "macros.h" +#include "traits.h" +#include "types.h" + +namespace wl +{ + +template +union _vec; + +template +union _vec<16u, T> +{ + static_assert(is_arithmetic_v, WL_ERROR_INTERNAL); + using base_type = value_type_t; + using storage_type = + std::conditional_t, __m128d, + std::conditional_t, __m128, __m128i>>; + storage_type data; + T values[16u / sizeof(T)]; +}; + +template +union _vec +{ + static_assert(is_arithmetic_v, WL_ERROR_INTERNAL); + using base_type = value_type_t; + using storage_type = + std::conditional_t, __m256d, + std::conditional_t, __m256, __m256i>>; + storage_type data; + T values[16u / sizeof(T)]; +}; + +template +auto _convert() +{ +} + +//template +//auto _add(const X& x, const Y& y) +//{ +// using XV = value_type_t; +// using YV = value_type_t; +// using C = common_type_t; +// if constexpr (is_complex_v) +// { +// if constexpr (is_complex_v) +// return complex(std::real(x) + std::real(y), +// std::imag(x) + std::imag(y)); +// else +// return complex(std::real(x) + cast(y), std::imag(x)); +// } +// else +// { +// if constexpr (is_complex_v) +// return complex(cast(x) + std::real(y), std::imag(y)); +// else +// return cast(cast(x) + cast(y)); +// } +//} + +} + diff --git a/src/math_compile.h b/IncludeFiles/math_compile.h similarity index 100% rename from src/math_compile.h rename to IncludeFiles/math_compile.h diff --git a/src/mathfunction.h b/IncludeFiles/mathfunction.h similarity index 100% rename from src/mathfunction.h rename to IncludeFiles/mathfunction.h diff --git a/src/ndarray.h b/IncludeFiles/ndarray.h similarity index 100% rename from src/ndarray.h rename to IncludeFiles/ndarray.h diff --git a/src/numerical.h b/IncludeFiles/numerical.h similarity index 100% rename from src/numerical.h rename to IncludeFiles/numerical.h diff --git a/src/random.h b/IncludeFiles/random.h similarity index 100% rename from src/random.h rename to IncludeFiles/random.h diff --git a/src/traits.h b/IncludeFiles/traits.h similarity index 100% rename from src/traits.h rename to IncludeFiles/traits.h diff --git a/src/types.h b/IncludeFiles/types.h similarity index 100% rename from src/types.h rename to IncludeFiles/types.h diff --git a/src/utils.h b/IncludeFiles/utils.h similarity index 100% rename from src/utils.h rename to IncludeFiles/utils.h diff --git a/src/view_derive.h b/IncludeFiles/view_derive.h similarity index 100% rename from src/view_derive.h rename to IncludeFiles/view_derive.h diff --git a/MathCompile.wl b/MathCompile.wl index e398363..113e04a 100644 --- a/MathCompile.wl +++ b/MathCompile.wl @@ -915,7 +915,7 @@ loadfunction[libpath_String,funcid_String,args_]:= ] -$template=Import[$packagepath<>"/src/src_template.cpp","Text"]; +$template=Import[$packagepath<>"/SourceFiles/src_template.cpp","Text"]; Options[compilelink]={ "LibraryDirectory"->"TargetDirectory"/.Options[CCompilerDriver`CreateLibrary], @@ -952,7 +952,7 @@ compilelink[f_,uncompiled_,OptionsPattern[]]:= {" ",",\n ",""}], "funcid"->funcid |>]; - If[FileExistsQ[$packagepath<>"/src/math_compile.h"]=!=True, + If[FileExistsQ[$packagepath<>"/IncludeFiles/math_compile.h"]=!=True, Message[link::noheader];Return[$Failed]]; mldir=$InstallationDirectory<> "/SystemFiles/Links/MathLink/DeveloperKit/"<>$SystemID<>"/CompilerAdditions"; @@ -970,7 +970,7 @@ compilelink[f_,uncompiled_,OptionsPattern[]]:= OptionValue["CompileOptions"] }, "CleanIntermediate"->!TrueQ@OptionValue["Debug"], - "IncludeDirectories"->{mldir,$packagepath<>"/src"}, + "IncludeDirectories"->{mldir,$packagepath<>"/IncludeFiles"}, "LibraryDirectories"->{mldir}; "Libraries"->{"ML64i4"}, "WorkingDirectory"->workdir, diff --git a/PacletInfo.wl b/PacletInfo.wl new file mode 100644 index 0000000..9ea76b4 --- /dev/null +++ b/PacletInfo.wl @@ -0,0 +1,11 @@ +(* ::Package:: *) + +Paclet[ + Name -> "MathCompile", + Version -> "0.1.1", + WolframVersion -> "11.3+", + Updating -> Automatic, + Extensions -> { + {"Kernel", Root -> ".", Context -> {"MathCompile`"}} + } +] diff --git a/src/src_template.cpp b/SourceFiles/src_template.cpp similarity index 100% rename from src/src_template.cpp rename to SourceFiles/src_template.cpp