Skip to content

Conversation

@rajithv
Copy link
Contributor

@rajithv rajithv commented Jun 9, 2016

Wrappers for the function symbol class

VALUE cfunction_functionsymbol_init(VALUE self, VALUE args)
{
int argc = NUM2INT(rb_funcall(args, rb_intern("length"), 0, NULL));
printf("argc : %d\n", argc);
Copy link
Contributor

Choose a reason for hiding this comment

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

The function shouldn't print anything.

@rajithv rajithv changed the title [WIP] Function symbol Ruby Wrappers Function symbol Ruby Wrappers Jun 10, 2016
@@ -1,2 +1,3 @@
b91c64a3b82f15133f4a7df64749523bb0bed185
1d80d81096b66c08ad3fe4e43ee586cd91b5ccf8

Copy link
Member

Choose a reason for hiding this comment

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

No need of these extra lines

@isuruf
Copy link
Member

isuruf commented Jun 11, 2016

Python wrappers have a nice syntax for creating FunctionSymbols.

func = Function('f')
Above would create an UndefFunction object which is a Python class, and
func(x, 2*y) would create a FunctionSymbol f(x, 2*y).

What do you think?

@rajithv
Copy link
Contributor Author

rajithv commented Jun 11, 2016

@isuruf What are the advantages of doing it in two steps?

What about, haveing SymEngine::Function('f', x, 2*y) as an alias for SymEngine::FunctionSymbol.new(...) ?

it { is_expected.to be_a SymEngine::Subs }
end

context 'by constant' do
Copy link
Member

Choose a reason for hiding this comment

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

Remove this. Differentiation should throw an error if the input is not a Symbol.

@isuruf
Copy link
Member

isuruf commented Jun 12, 2016

Advantage is for easy typing when there are multiple function symbols made and also for readability

f = Function('f')
g = f(x, y) - 2 * f(y - x, x)

instead of

g = FunctionSymbol.new("f", x, y) - 2 * FunctionSymbol.new("f", y - x, x)

lib/symengine.rb Outdated
end
end

def SymEngine.Function(n)
Copy link
Member

Choose a reason for hiding this comment

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

You can move this inside class << self block and then you can remove SymEngine.

@isuruf isuruf merged commit a7b1d13 into symengine:master Jun 14, 2016
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