Scientific Computing with Scala - Vytautas Jancauskas - E-Book

Scientific Computing with Scala E-Book

Vytautas Jancauskas

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Learn to solve scientific computing problems using Scala and its numerical computing, data processing, concurrency, and plotting libraries

About This Book

  • Parallelize your numerical computing code using convenient and safe techniques.
  • Accomplish common high-performance, scientific computing goals in Scala.
  • Learn about data visualization and how to create high-quality scientific plots in Scala

Who This Book Is For

Scientists and engineers who would like to use Scala for their scientific and numerical computing needs. A basic familiarity with undergraduate level mathematics and statistics is expected but not strictly required. A basic knowledge of Scala is required as well as the ability to write simple Scala programs. However, complicated programming concepts are not used in the book. Anyone who wants to explore using Scala for writing scientific or engineering software will benefit from the book.

What You Will Learn

  • Write and read a variety of popular file formats used to store scientific data
  • Use Breeze for linear algebra, optimization, and digital signal processing
  • Gain insight into Saddle for data analysis
  • Use ScalaLab for interactive computing
  • Quickly and conveniently write safe parallel applications using Scala's parallel collections
  • Implement and deploy concurrent programs using the Akka framework
  • Use the Wisp plotting library to produce scientific plots
  • Visualize multivariate data using various visualization techniques

In Detail

Scala is a statically typed, Java Virtual Machine (JVM)-based language with strong support for functional programming. There exist libraries for Scala that cover a range of common scientific computing tasks – from linear algebra and numerical algorithms to convenient and safe parallelization to powerful plotting facilities. Learning to use these to perform common scientific tasks will allow you to write programs that are both fast and easy to write and maintain.

We will start by discussing the advantages of using Scala over other scientific computing platforms. You will discover Scala packages that provide the functionality you have come to expect when writing scientific software. We will explore using Scala's Breeze library for linear algebra, optimization, and signal processing. We will then proceed to the Saddle library for data analysis. If you have experience in R or with Python's popular pandas library you will learn how to translate those skills to Saddle. If you are new to data analysis, you will learn basic concepts of Saddle as well. Well will explore the numerical computing environment called ScalaLab. It comes bundled with a lot of scientific software readily available. We will use it for interactive computing, data analysis, and visualization. In the following chapters, we will explore using Scala's powerful parallel collections for safe and convenient parallel programming. Topics such as the Akka concurrency framework will be covered. Finally, you will learn about multivariate data visualization and how to produce professional-looking plots in Scala easily. After reading the book, you should have more than enough information on how to start using Scala as your scientific computing platform

Style and approach

Examples are provided on how to use Scala to do basic numerical and scientific computing tasks. All the concepts are illustrated with more involved examples in each chapter. The goal of the book is to allow you to translate existing experience in scientific computing to Scala.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 277

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Scientific Computing with Scala
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introducing Scientific Computing with Scala
Why Scala for scientific computing?
What are the advantages compared to C/C++/Java?
What are the advantages compared to MATLAB/Python/R?
Scala does parallelism well
Any downsides?
Numerical computing packages for Scala
Scalala
Breeze
ScalaLab
Data analysis packages for Scala
Saddle
MLlib
Other scientific software
FACTORIE
Cassovary
Figaro
Alternatives for doing plotting
Using Emacs as the Scala IDE
Profiling Scala code
Debugging Scala code
Building, testing, and distributing your Scala software
Directory structure
Testing Scala code with the help of SBT
ENSIME and SBT integration
Distributing your software
Mixing Java and Scala code
Summary
2. Storing and Retrieving Data
Reading and writing CSV files
Reading files in Scala
Parsing CSV data
Processing CSV data
Reading and writing JSON files
Spray-JSON
SON of JSON
Argonaut
Reading and writing XML files
Database access using JDBC
Database access using Slick
Plain SQL
Reading and writing HDF5 files
Summary
3. Numerical Computing with Breeze
Using Breeze in your project
Basic Breeze data structures
DenseVector
DenseMatrix
Indexing and slicing
Reshaping
Concatenation
Statistical computing with Breeze
Optimization
Signal processing
Fourier transforms
Other signal processing functionality
Cheat sheet
Creating matrices and vectors
Operations on matrices and vectors
Summary
4. Using Saddle for Data Analysis
Installing Saddle
Basic Saddle data structures
Using the Vec structure
Using arithmetic operations in Vec
Data access in Vec
Implementing the slice method in Vec
Statistic calculation in Vec
Using the Mat structure
Creating a matrix with Mat
Applying arithmetic operators in Mat structures
Using Matrix in the Mat structure
Series
Implementing the groupBy method in the Series structure
Applying the transform method in Series
Using numerical operators in Series
Joining Series using the join operation
Applying index.LeftJoin
Applying index.RightJoin
Applying index.InnerJoin
Applying index.OuterJoin
Frame
Using the rowAt method in Frame
Using the sortedColsBy method in Frame
Data analysis with Saddle
Using Breeze with Saddle
Summary
5. Interactive Computing with ScalaLab
Installing and running ScalaLab
Basic ScalaSci data structures
Vector
Matrix
Other ScalaSci functionality
Data storage and retrieval
Plotting with ScalaLab
Other ScalaLab features
Doing symbolic algebra using symja
Summary
6. Parallel Programming in Scala
Programming with Scala threads
A simple Scala thread example
Synchronization
Monte-Carlo pi calculation
Using Scala's parallel collections
Agent-based concurrency with the Akka framework
Monte-Carlo pi revisited
Using routing
Waiting for a reply
Summary
7. Cluster Computing Using Scala
Using MPJ Express for distributed computing
Setting up and running MPJ Express
Using Send and Recv
Sending Scala objects in MPJ Express messages
Non-blocking communication
Scatter and Gather
Setting up MPJ Express on clusters
Using an Akka cluster for distributed computing
Summary
8. Scientific Plotting with Scala
Plotting with JFreeChart
Using JFreeChart in your project
Creating a line plot
Creating a histogram
Creating a bar chart
Creating a box-and-whisker chart
Other plot types
Saving charts to a file
Plotting with scala-chart
Installing scala-chart
Creating a line plot
Creating a histogram
Creating a bar chart
Creating a box-and-whisker chart
Saving charts to a file
Plotting with Wisp
Creating a line plot
Creating a histogram
Creating a bar chart
Creating a box-and-whisker chart
Creating a linear regression plot
Interacting with the server
Summary
9. Visualizing Multi-Dimensional Data in Scala
Obtaining data to visualize
Andrews curve
Parallel coordinates
Scatter plot matrix
Sammon mapping
Improving the program
Summary
Index

Scientific Computing with Scala

Scientific Computing with Scala

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2016

Production reference: 1220416

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-694-2

www.packtpub.com

Credits

Author

Vytautas Jančauskas

Reviewer

Chetan Khatri

Commissioning Editor

Amarabha Banerjee

Acquisition Editors

Ruchita Bhansali

Sonali Vernekar

Content Development Editor

Kajal Thapar

Technical Editor

Prajakta Mhatre

Copy Editor

Charlotte Carneiro

Project Coordinator

Shweta H Birwatkar

Proofreader

Safis Editing

Indexer

Rekha Nair

Graphics

Kirk D'Penha

Production Coordinator

Manu Joseph

Cover Work

Manu Joseph

About the Author

Vytautas Jančauskas is a computer science PhD student and lecturer at Vilnius University. At the time of writing, he was about to get a PhD in computer science. The thesis concerns multiobjective optimization using nature-inspired optimization methods. Throughout the years, he has worked on a number of open source projects that have to do with scientific computing. These include Octave, pandas, and others. Currently, he is working with numerical codes with astrophysical applications.

He has experience writing code to be run on supercomputers, optimizing code for performance, and interfacing C code to higher-level languages. He has been teaching computer networks, operating systems design, C programming, and computer architecture to computer science and software engineering undergraduates at Vilnius University for 4 years now.

His primary research interests include optimization, numerical algorithms, programming language design, and software engineering. Vytautas has significant experience with various different programming languages. He has written simple programs and has participated in projects using Scheme, Common Lisp, Python, C/C++, and Scala. He has experience working as a Unix systems administrator. He also has significant experience working with numerical computing platforms such as NumPy/MATLAB and data analysis frameworks such pandas and R.

I would like to thank my wife for being patient and giving me time to write this book.

About the Reviewer

Chetan Khatri is data science researcher with over four and a half years of experience in research and development. He works as a principal engineer in data and machine learning at Nazara Technologies Pvt. Ltd. Previously, he worked with R&D Lab, Eccella Corporation. He completed his masters in computer science and minor in data science from KSKV Kachchh University and was a gold medalist.

He contributes to society in various ways, including giving talks to sophomore students at University. He also gives talks on various fields of data science at academia and conferences. He helps the community by providing a data science platform, and loves to participate in data science hackathons. He is one of the founding member of PyKutch—a Python community. Currently, he is exploring deep neural networks and reinforcement learning for government data.

I would like to thank Prof. Devji Chhanga, Head of the Computer Science department, University of Kachchh, for showing me the correct path and for valuable guidance in the field of data science research.

I would like to thank my beloved family.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and readPackt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Preface

In this book, we will look into using Scala as a scientific computing platform. It is intended for people who already have experience with scientific computing and Scala. We will see how to do things that are possible in other numerical/scientific computing platforms in Scala. We will cover numerical computation, data storage and retrieval, structured data analysis, interactive computing, visualization, and other important topics.

What this book covers

Chapter 1, Introducing Scientific Computing with Scala, looks into the feasibility of using Scala for scientific computing. An overview of the state-of-the-art libraries and tools in Scala scientific computing is given here.

Chapter 2, Storing and Retrieving Data, provides various options for storing and retrieving data in Scala. Popular data storage and retrieval formats that you may encounter in scientific computing are explored.

Chapter 3, Numerical Computing with Breeze, is about using the Breeze library for numerical computing.

Chapter 4, Using Saddle for Data Analysis, explores the functionality of the Saddle library for structured data analysis and manipulation.

Chapter 5, Interactive Computing with ScalaLab, explores the possibilities offered by the ScalaLab environment for interactive computing.

Chapter 6, Parallel Programming in Scala, is about parallel programming in Scala. Various techniques, including JVM threads, parallel collections, and actor-based concurrency with Akka, are covered.

Chapter 7, Cluster Computing Using Scala, teaches how to use Scala programs in distributed computing environments and shows how to use MPI from Scala, and more.

Chapter 8, Scientific Plotting with Scala, gives various options for carrying out plots in Scala.

Chapter 9, Visualizing Multi-Dimensional Data in Scala, elaborates on advanced plotting and visualization.

What you need for this book

You will need Scala and SBT installed on your system. Technically, you only need SBT, since SBT will install the required version of Scala for you. You can get Scala and SBT from the following websites:

http://www.scala-lang.org/http://www.scala-sbt.org/

It is advisable that you use a UNIX-like operating system for this book. However, this is not strictly necessary for most chapters. You will also need a Scala IDE or a text editor. Setting up Emacs to work with Scala and SBT is covered in the book. Alternatively, you can use any editor you are comfortable with.

Who this book is for

This book is for scientists and engineers who would like to use Scala for their scientific and numerical computing needs. Basic familiarity with undergraduate-level mathematics and statistics is expected but not strictly required. Basic knowledge of Scala is required as well as the ability to write simple Scala programs. Complicated programming concepts are not used in the book. Anyone who wants to explore using Scala for writing scientific or engineering software will benefit from the book.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/ScientificComputingwithScala_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.