Skip to content

Commit

Permalink
TMP add lapack_internal.hh
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Jun 30, 2024
1 parent 405d62a commit 03d9c35
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/lapack_internal.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2017-2023, University of Tennessee. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// This program is free software: you can redistribute it and/or modify it under
// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.

#ifndef LAPACK_INTERNAL_HH
#define LAPACK_INTERNAL_HH

#include "lapack/util.hh"

namespace lapack {

//------------------------------------------------------------------------------
/// @see to_lapack_int
///
inline lapack_int to_lapack_int_( int64_t x, const char* x_str )
{
if constexpr (sizeof(int64_t) > sizeof(lapack_int)) {
lapack_error_if_msg( x > std::numeric_limits<lapack_int>::max(), "%s", x_str );
}
return lapack_int( x );
}

//----------------------------------------
/// Convert int64_t to lapack_int.
/// If lapack_int is 64-bit, this does nothing.
/// If lapack_int is 32-bit, throws if x > INT_MAX, so conversion would overflow.
///
/// Note this is in src/lapack_internal.hh, so this macro won't pollute
/// the namespace when apps #include <lapack.hh>.
///
#define to_lapack_int( x ) lapack::to_lapack_int_( x, #x )

} // namespace lapack

#endif // LAPACK_INTERNAL_HH

0 comments on commit 03d9c35

Please sign in to comment.