Arcane  4.2.1.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArrayViewDumper.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ArrayViewDumper.h (C) 2000-2026 */
9/* */
10/* Fonctions pour afficher les valeurs des vues de tableaux Arccore */
11/* (ArrayView, Span, ...) */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCCORE_BASE_ARRAYVIEWDUMPER_H
14#define ARCCORE_BASE_ARRAYVIEWDUMPER_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
19
20#include <iosfwd>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Impl
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
37template <typename ViewType>
39{
40 public:
41
42 template <typename Stream> static void
43 dumpArray(Stream& o, ViewType val, int max_print)
44 {
45 using size_type = typename ViewType::size_type;
46 size_type n = val.size();
47 if (max_print > 0 && n > max_print) {
48 // Affiche uniquement le premier (max_print/2) et le dernier (max_print/2)
49 // sinon, si le tableau est très grand, il peut générer des listes de sortie énormes.
50 size_type z = (max_print / 2);
51 size_type z2 = n - z;
52 o << "[0]=\"" << val[0] << '"';
53 for (size_type i = 1; i < z; ++i)
54 o << " [" << i << "]=\"" << val[i] << '"';
55 o << " ... ... (skipping indexes " << z << " to " << z2 << " ) ... ... ";
56 for (size_type i = (z2 + 1); i < n; ++i)
57 o << " [" << i << "]=\"" << val[i] << '"';
58 }
59 else {
60 for (size_type i = 0; i < n; ++i) {
61 if (i != 0)
62 o << ' ';
63 o << "[" << i << "]=\"" << val[i] << '"';
64 }
65 }
66 }
67};
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72} // namespace Arcane::Impl
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77#endif
Définitions et globaux de Arccore.
Classe utilitaire pour afficher une vue de tableau sur un flux.
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:325
Concept for reading and writing characters.