-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1436 from DARMA-tasking/1435-print-time-units-for…
…-lb-times 1435: Print time units and adjust accordingly for LB times
- Loading branch information
Showing
45 changed files
with
686 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
project(EngFormat-Cpp CXX) | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
add_library(${PROJECT_NAME} include/EngFormat-Cpp/eng_format.hpp src/eng_format.cpp) | ||
|
||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
include(CTest) | ||
if(BUILD_TESTING) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE ENG_FORMAT_MICRO_GLYPH="u") | ||
add_subdirectory(test) | ||
endif() | ||
endif() | ||
|
||
install( | ||
DIRECTORY include/EngFormat-Cpp | ||
DESTINATION include | ||
CONFIGURATIONS ${build_type_list} | ||
FILES_MATCHING PATTERN "*" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright (C) 2005-2009 by Jukka Korpela | ||
// Copyright (C) 2009-2013 by David Hoerl | ||
// Copyright (C) 2013 by Martin Moene | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#ifndef ENG_FORMAT_H_INCLUDED | ||
#define ENG_FORMAT_H_INCLUDED | ||
|
||
#include <string> | ||
|
||
/** | ||
* convert a double to the specified number of digits in SI (prefix) or | ||
* exponential notation, optionally followed by a unit. | ||
*/ | ||
std::string | ||
to_engineering_string( double value, int digits, bool exponential, std::string unit = "", std::string separator = " " ); | ||
|
||
/** | ||
* convert the output of to_engineering_string() into a double. | ||
*/ | ||
double | ||
from_engineering_string( std::string text ); | ||
|
||
/** | ||
* step a value by the smallest possible increment. | ||
*/ | ||
std::string | ||
step_engineering_string( std::string text, int digits, bool exponential, bool increment ); | ||
|
||
// | ||
// Extended interface: | ||
// | ||
|
||
/** | ||
* \var eng_prefixed | ||
* \brief select SI (prefix) presentation: to_engineering_string(), step_engineering_string(). | ||
*/ | ||
|
||
/** | ||
* \var eng_exponential | ||
* \brief select exponential presentation: to_engineering_string(), step_engineering_string(). | ||
*/ | ||
|
||
extern struct eng_prefixed_t {} eng_prefixed; | ||
extern struct eng_exponential_t {} eng_exponential; | ||
|
||
/** | ||
* \var eng_increment | ||
* \brief let step_engineering_string() make a postive step. | ||
*/ | ||
|
||
/** | ||
* \var eng_decrement | ||
* \brief let step_engineering_string() make a negative step. | ||
*/ | ||
|
||
constexpr bool eng_increment = true; | ||
constexpr bool eng_decrement = false; | ||
|
||
/** | ||
* convert a double to the specified number of digits in SI (prefix) notation, | ||
* optionally followed by a unit. | ||
*/ | ||
inline std::string | ||
to_engineering_string( double value, int digits, eng_prefixed_t, std::string unit = "", std::string separator = " " ) | ||
{ | ||
return to_engineering_string( value, digits, false, unit, separator ); | ||
} | ||
|
||
/** | ||
* convert a double to the specified number of digits in exponential notation, | ||
* optionally followed by a unit. | ||
*/ | ||
inline std::string | ||
to_engineering_string( double value, int digits, eng_exponential_t, std::string unit = "", std::string separator = " " ) | ||
{ | ||
return to_engineering_string( value, digits, true, unit, separator ); | ||
} | ||
|
||
/** | ||
* step a value by the smallest possible increment, using SI notation. | ||
*/ | ||
inline std::string | ||
step_engineering_string( std::string text, int digits, eng_prefixed_t, bool increment ) | ||
{ | ||
return step_engineering_string( text, digits, false, increment ); | ||
} | ||
|
||
/** | ||
* step a value by the smallest possible increment, using exponential notation. | ||
*/ | ||
inline std::string | ||
step_engineering_string( std::string text, int digits, eng_exponential_t, bool increment ) | ||
{ | ||
return step_engineering_string( text, digits, true, increment ); | ||
} | ||
|
||
#endif // ENG_FORMAT_H_INCLUDED |
Oops, something went wrong.