Skip to content

Add rand(numRows: Int, numCols: Int) functions #14422

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

Closed
wants to merge 2 commits into from

Conversation

xubo245
Copy link
Contributor

@xubo245 xubo245 commented Jul 30, 2016

What changes were proposed in this pull request?

(Please fill in changes proposed in this fix)

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)

(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)

add rand(numRows: Int, numCols: Int) functions to DenseMatrix object,like breeze.linalg.DenseMatrix.rand()

add rand(numRows: Int, numCols: Int) functions to DenseMatrix object,like breeze.linalg.DenseMatrix.rand()
@xubo245
Copy link
Contributor Author

xubo245 commented Jul 30, 2016

we can use it to replace breeze.linalg.DenseMatrix.rand(numRows: Int, numCols: Int)

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

def rand(numRows: Int, numCols: Int): DenseMatrix = {
require(numRows.toLong * numCols <= Int.MaxValue,
s"$numRows x $numCols dense matrix is too large to allocate")
new DenseMatrix(numRows, numCols, Array.fill(numRows * numCols)((new Random).nextDouble()))
Copy link
Member

Choose a reason for hiding this comment

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

This makes a new RNG for every element, which isn't great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can fix RNG, This makes a new RNG for all element :
val rng = new Random()
new DenseMatrix(numRows, numCols, Array.fill(numRows * numCols)(rng.nextDouble()))

fix RNG , his makes a new RNG for All element
@HyukjinKwon
Copy link
Member

HyukjinKwon commented Jul 30, 2016

Doesn't that need a JIRA, test and PR description maybe?

@xubo245
Copy link
Contributor Author

xubo245 commented Jul 30, 2016

I add test : #14424

@HyukjinKwon
Copy link
Member

HyukjinKwon commented Jul 30, 2016

I guess it might be nicer if the contributions you make follow https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark just like other contributions and I believe usually we put a test together in the related patch ( not in a separate PR)..

@xubo245
Copy link
Contributor Author

xubo245 commented Jul 31, 2016

@HyukjinKwon Thank you.
This is my first time to push request to spark, Sorrry, I will follow the https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark later.

@srowen
Copy link
Member

srowen commented Jul 31, 2016

Please don't open other PRs for related changes. Usually, you also need a JIRA. Although I understand the use for these methods, is there any use for them in Spark? we probably wouldn't add these things unless Spark itself needed them a few places, or else it was clearly a common task. I am not clear these are.

@xubo245
Copy link
Contributor Author

xubo245 commented Aug 7, 2016

@srowen sorry, please close the issue. I will learning more before next PR. The PR is only because breeze have the function. In spark ,there is no use for them.
Could you tell me some issue for starter? Please.

@srowen
Copy link
Member

srowen commented Aug 8, 2016

@xubo245 you need to close the issues, we can't do so directly.

@xubo245 xubo245 closed this Aug 9, 2016
@xubo245
Copy link
Contributor Author

xubo245 commented Aug 9, 2016

ok

@xubo245 xubo245 reopened this Aug 9, 2016
@xubo245 xubo245 closed this Aug 9, 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.

4 participants