Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming scheme for vector classes #18

Open
pelesh opened this issue Oct 18, 2023 · 1 comment
Open

Naming scheme for vector classes #18

pelesh opened this issue Oct 18, 2023 · 1 comment
Assignees

Comments

@pelesh
Copy link
Collaborator

pelesh commented Oct 18, 2023

It might be a good idea to decide on vector naming schemes. I think it would be important to have these schemes analog to what we settled on for matrices. Here are a few suggestions:

  • Rename namespace vector to multivector. Then rename Vector class to Dense in analogy with matrix objects. The class will be called as multivector::Dense, i.e. this convention would include that using namespace multivector is never invoked.
  • Alternatively, we could keep the namespace as vector and rename the class MultiDense, so the invocation of the type name would be vector::MultiDense. This name is a little bit cumbersome, but it also allows us to derive single vector from multivector class trivially and then have another type name vector::SingleDense. This may provide more flexibility.

Once we decide, it is straightforward to update names of classes and files.

@kswirydo @cameronrutherford @rothpc please chime in.

@pelesh
Copy link
Collaborator Author

pelesh commented Oct 18, 2023

Looking at vec_dev branch and the work @kswirydo charted there, I suggest following vector classes naming scheme:

namespace vector { namespace dense {
  class Multi {
    // dense multivector class declaration
  };
}}

The vector object should be called with both namespaces preceding it explicitly:

vector::dense::Multi vec;

This way, namespaces protect from name conflicts for vector classes and help code readability.

Alternatively, with this naming scheme we could take advantage of using statement like this:

using vector_type = vector::dense::Multi;
// some code
vector_type vec;

Here we define type vector_type that we want to use in this scope exclusively. We have a line that shows what vector_type is, and we use it as a short hand notation through the rest of the scope. If we change the first line, we are guaranteed to have a wholesale change within the entire scope.

On the other hand, using statements like this should be discouraged with this notation:

using namespace vector::dense;
// 300 lines of code
Multi vec;

If we change using statement here, we still need to verify that each instance of Multi (1) exists in the new namespace and (2) is used correctly.

A single vector class can be derived from Multi vector almost trivially:

namespace vector { namespace dense {
  class Single : public Multi {
    public:
      Single() : Multi(numVectors = 1)
      {}
    // some code
  };
}}

If we decide to implement e.g. our own matrix factorization, we will need a sparse vector object. In that case we could extend this naming scheme and define sparse vector class in different namespace like this:

namespace vector { namespace sparse {
  class Multi {
    // sparse multivector class declaration
  };
}}

Feedback is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants