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

adding support for linear algebra operators #54

Merged
merged 6 commits into from
Feb 13, 2014

Conversation

lileicc
Copy link
Contributor

@lileicc lileicc commented Feb 12, 2014

  1. vector plus, minus (result is a vector, i.e. Real[])
  2. vector scalar multiplication (result is a vector, i.e. Real[])
  3. scalar vector multiplication (result is a vector, i.e. Real[])
  4. matrix plus, minus, multiplication (result is a matrix, i.e.
    Real[][])
  5. matrix scalar multiplication (result is a matrix, i.e. Real[][])
  6. scalar matrix multiplication (result is a matrix, i.e. Real[][])
  7. matrix vector multiplication (result is a matrix, i.e. Real[][])
  8. vector matrix multiplication (result is a vector, i.e. Real[])
  9. matrix inverse (result is Real[][])
  10. matrix determinant (result is Real)
  11. subscript expression. Result is row vector for Real[][], and Real scalar for Real[]. The index can be random Integer as well.

1. vector plus, minus (result is a vector, i.e. Real[])
2. vector scalar multiplication (result is a vector, i.e. Real[])
3. scalar vector multiplication (result is a vector, i.e. Real[])
4. matrix plus, minus, multiplication (result is a matrix, i.e.
Real[][])
5. matrix scalar multiplication (result is a matrix, i.e. Real[][])
6. scalar matrix multiplication (result is a matrix, i.e. Real[][])
7. matrix vector multiplication (result is a matrix, i.e. Real[][])
8. vector matrix multiplication (result is a vector, i.e. Real[])
9. matrix inverse (result is Real[][])
10. matrix determinant (result is Real)
@lileicc lileicc added this to the PPAML half year review milestone Feb 12, 2014
/**
* ArrayType for BLOG
* e.g. Real[] will be ArrayType(Type("Real"), 1);
* e.g. Real[] will be ArrayType(Type("Real"), 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant [][] on the line above

@cberzan
Copy link
Contributor

cberzan commented Feb 12, 2014

@lileicc Looks good, and I verified that the example works. Go ahead and merge 👍

@cberzan
Copy link
Contributor

cberzan commented Feb 12, 2014

@lileicc By the way, to avoid merge pain in the future, if we have to change the whitespace / indentation of a file, let's do this:

  1. pull request that changes the whitespace / indentation AND NOTHING ELSE
  2. merge the above into master
  3. another pull request that does the actual changes to the code

That will make reviewing / merging into existing branches much easier.

@lileicc
Copy link
Contributor Author

lileicc commented Feb 13, 2014

Does ?w=1 work?

On Wed, Feb 12, 2014 at 3:32 PM, cberzan notifications@github.com wrote:

@lileicc https://github.com/lileicc By the way, to avoid merge pain in
the future, if we have to change the whitespace / indentation of a file,
let's do this:

  1. pull request that changes the whitespace / indentation AND NOTHING ELSE
  2. another pull request that does the actual changes to the code

That will make reviewing / merging into existing branches much easier.

Reply to this email directly or view it on GitHubhttps://github.com//pull/54#issuecomment-34931703
.

@cberzan
Copy link
Contributor

cberzan commented Feb 13, 2014

Does ?w=1 work?

It works, but when in this mode, you can't make comments on the diff.

Anyway, doesn't matter for this PR, just for the future.

lileicc added a commit that referenced this pull request Feb 13, 2014
adding support for linear algebra operators
@lileicc lileicc merged commit 474054c into master Feb 13, 2014
@lileicc lileicc deleted the linear-algebra-operators branch February 13, 2014 11:48
@cberzan
Copy link
Contributor

cberzan commented Feb 13, 2014

@lileicc For the automobile model I need to add scalars and vectors. Minimalist example:

fixed Real laser_theta = 1.23;
fixed Real[] laser_angles = [1.0; 2.0; 3.0];
fixed Real[] sum = laser_theta + laser_angles;

query sum;

Currently this doesn't work. Should we also add functions "scalar op vec", "scalar op mat", "vec op scalar", and "mat op scalar"?

@cberzan
Copy link
Contributor

cberzan commented Feb 14, 2014

@lileicc Also, how do I take an indicator function in BLOG? For example, I need a function y = f(x) s.t. y[i] = 1 if x[i] >= 0, and 0 otherwise.

@WilliamCushing
Copy link
Contributor

random Real y(Real x) ~ if (x>=0) 1 else 0;

"fixed" and "=" might also work, and would surely be dramatically more
efficient if it does. I might have made a small syntax error, but I know
for sure that something like the above does work; I used the trick to get
BLOG to do purely logical inference in another model.

-Will

On Thu, Feb 13, 2014 at 4:04 PM, cberzan notifications@github.com wrote:

@lileicc https://github.com/lileicc Also, how do I take an indicator
function in BLOG? For example, I need a function y = f(x) s.t. y[i] = 1 if
x[i] >= 0, and 0 otherwise.

Reply to this email directly or view it on GitHubhttps://github.com//pull/54#issuecomment-35042061
.

@cberzan cberzan mentioned this pull request Feb 14, 2014
17 tasks
lileicc added a commit that referenced this pull request Jun 28, 2014
adding support for linear algebra operators
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

Successfully merging this pull request may close these issues.

3 participants