MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / print

Method print

XM/include/Utils/memory.h:444–476  ·  view source on GitHub ↗

Print matrix, if matrix is larger the 3-dimension then donot print

Source from the content-addressed store, hash-verified

442
443 // Print matrix, if matrix is larger the 3-dimension then donot print
444 void print() {
445 if(vals_host == nullptr){
446 // always Synchronize to avoid read-write conflict
447 SynchronizeDevicetoHost();
448 }
449 if(num_dims == 1){
450 for (size_s j = 0; j < dimensions[0]; j++) {
451 if(CudaTypeMapper<T>::value == CUDA_R_64F || CudaTypeMapper<T>::value == CUDA_R_32F){
452 std::printf("%1.3e, ", vals_host[j]);
453 }
454 else{
455 std::printf("%d, ", vals_host[j]);
456 }
457
458 }
459 std::printf("\n");
460 }else if(num_dims == 2){
461 for (size_s i = 0; i < dimensions[0]; i++) {
462 for (size_s j = 0; j < dimensions[1]; j++) {
463 if(CudaTypeMapper<T>::value == CUDA_R_64F || CudaTypeMapper<T>::value == CUDA_R_32F){
464 std::printf("%1.3e, ", vals_host[j * dimensions[0] + i]);
465 }
466 else{
467 std::printf("%d, ", vals_host[j * dimensions[0] + i]);
468 }
469 }
470 std::printf(";\n");
471 }
472 }else{
473 std::cout << "Matrix dimension larger than 2" << std::endl;
474 }
475 std::printf("\n");
476 }
477
478 ~DeviceDnTen() {
479 CHECK_CUDA(cudaSetDevice(this->gpu_id));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected