File indexing completed on 2026-04-09 07:49:45
0001 #include <iostream>
0002 #include <iomanip>
0003 #include <string>
0004 #include <sstream>
0005 #include <vector>
0006
0007 #include <glm/glm.hpp>
0008 #include <glm/gtc/type_ptr.hpp>
0009 #include "scuda.h"
0010
0011
0012 template<typename T>
0013 inline std::string SPresent(const T* vv, unsigned n, const char* label, const char* mode )
0014 {
0015 int lw = 15 ;
0016 int w = 10 ;
0017 std::stringstream ss ;
0018 if(label) ss << std::setw(lw) << label << " " ;
0019 if(mode) ss << std::setw(lw) << mode << " " ;
0020
0021 for(unsigned i=0 ; i < n ; i++)
0022 {
0023 if( n > 4 && i % 4 == 0 )
0024 {
0025 ss << std::endl << std::setw(lw) << "" ;
0026 if(mode) ss << std::setw(lw) << "" << " " ;
0027 }
0028 ss << std::setw(w) << std::fixed << std::setprecision(3) << *(vv+i) ;
0029 }
0030 ss << " " ;
0031 std::string str = ss.str();
0032 return str ;
0033 }
0034
0035 template<typename T> std::string SPresent(const glm::tmat4x4<T>& m, const char* label, const char* mode=nullptr ){ return SPresent(glm::value_ptr(m), 16, label, mode); }
0036 template<typename T> std::string SPresent(const glm::tvec4<T>& v, const char* label, const char* mode=nullptr ){ return SPresent(glm::value_ptr(v), 4, label, mode); }
0037 template<typename T> std::string SPresent(const glm::tvec3<T>& v, const char* label, const char* mode=nullptr ){ return SPresent(glm::value_ptr(v), 3, label, mode); }
0038
0039 template<typename T>
0040 inline std::string SPresent(std::vector<glm::tvec4<T>>& vv )
0041 {
0042 int num_v = vv.size();
0043 std::stringstream ss ;
0044 for(int i=0 ; i < num_v ; i++) ss << SPresent<T>(vv[i], nullptr) << std::endl ;
0045 std::string str = ss.str();
0046 return str ;
0047 }
0048
0049 inline std::string SPresent(std::vector<float4>& vv )
0050 {
0051 int num_v = vv.size();
0052 std::stringstream ss ;
0053 for(int i=0 ; i < num_v ; i++) ss << vv[i] << std::endl ;
0054 std::string str = ss.str();
0055 return str ;
0056 }
0057
0058
0059