Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:20

0001 
0002 /**
0003 
0004 name=squadUnionTest ; gcc $name.cc -std=c++11 -lstdc++ -I.. -I/usr/local/cuda/include -o /tmp/$name && /tmp/$name
0005 
0006 https://stackoverflow.com/questions/252552/why-do-we-need-c-unions
0007 
0008 **/
0009 
0010 #include "scuda.h"
0011 #include "squad.h"
0012 
0013 union qstate2
0014 {
0015     struct 
0016     {   
0017         float m1_refractive_index ; 
0018         float m1_absorption_length ;
0019         float m1_scattering_length ; 
0020         float m1_reemission_prob ; 
0021 
0022         float m2_refractive_index ; 
0023         float m2_absorption_length ;
0024         float m2_scattering_length ; 
0025         float m2_reemission_prob ; 
0026 
0027     } field ;  
0028         
0029     quad2 q ;   
0030 };
0031 
0032 
0033 
0034 #include <iostream>
0035 
0036 int main()
0037 {
0038     qstate2 s ; 
0039     s.q.zero(); 
0040 
0041     s.field.m1_refractive_index = 1.f ; 
0042     s.field.m2_refractive_index = 1.5f ; 
0043  
0044     std::cout << "s.q.q0.f " << s.q.q0.f << std::endl ; 
0045     std::cout << "s.q.q1.f " << s.q.q1.f << std::endl ; 
0046 
0047 
0048     return 0 ; 
0049 }
0050