My purpose is to write a academic paper related to shared computing more abstractly and I need to refer to these variables in both equation and its corresponding pseudocode.

In my pseudocode I have nested structs, where it makes it harder to represent them in simplified equations.

Assume I have following nested structs in C. Jobs struct uses Fees struct. Fees could have additinal stuct inside and so on.

struct Fees {
    int cpu;
    int data;

struct Jobs {
   struct Fees F;
   int start_time;
   int completion_time;
   int run_time;
   int requested_cpu;

int main( ) {
   struct Jobs j;
   j.F.cpu = 20
   j.F.data = 10

   nproc = 4
   run_time = 60
   cost = j.F.cpu * nproc * run_time
   // ... //

In C code, I can access/represent the variable using j.F.cpu. Could I use same way as mathematical notation? or should I do subscript for the objects' variables, such as $j.F_{cpu}$? or should I do completely different approach?

Assume $j$ is a Job object. Alternative to $j.F.cpu$, I come up following subscripts examples:

  • $j.F^{cpu}$ == $j.F^{cpu}$
  • $j.F_{cpu}$ == $j.F_{cpu}$
  • $j_{F_{cpu}}$ == $j_{F_{cpu}}$
  • $j_{F^{cpu}}$ == $j_{F^{cpu}}$
  • $j_{F.{cpu}}$ == $j_{F.{cpu}}$

Related: How can I define programming struct variables as mathematical notation?

I am using following approach if there is not nested structs:

As a stylistic matter, I don't like j.X^{t}; I would just use j.X

  • $\begingroup$ I don't see a real need to reflect the structs at all in the mathematical explanation. By the way, Fees is used only once, so needn't even exist. $\endgroup$
    – user16034
    Commented Mar 4, 2022 at 16:30
  • $\begingroup$ I show fee usage once for a basic example, in my real implementation it is used more than once. $\endgroup$
    – alper
    Commented Mar 8, 2022 at 13:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.